//FIX Css Bug in specify navigator - this is master - should be copied to the specific location
function fixCSS() {
	jQuery(document).ready(function() {
		
		//MOSILLA
		if(jQuery.browser.mozilla){
			
		}
		else
		{
			//IE
			if (navigator.appVersion.indexOf('MSIE 6.0')>-1)
			{
				//IE 6
				
			}
			else
			{
				//IE 7
				
			}
		}
	});
}

//=========================================== TOP SEARCH ===============================================
function topSeachFocus(txtTopSearch){
	if(g_topSearchUpdated == false) {
		document.getElementById("txtTopSeach").value = "";
		document.getElementById("txtTopSeach").focus();
	}
}
//------------------------------------------------------------------------------------------------------
function topInpSeachClick(txtTopSearch){
	if(document.getElementById("txtTopSeach").value == g_topSearchInitText) {
		document.getElementById("txtTopSeach").value = "";
		document.getElementById("txtTopSeach").focus();
	}
}
//------------------------------------------------------------------------------------------------------
function topSearchBlur(txtTopSearch){
	if(txtTopSearch.value == "") txtTopSearch.value = g_topSearchInitText;
}
//------------------------------------------------------------------------------------------------------
function topSearchKeyUp(txtTopSearch,evt){
	g_topSearchUpdated = true;
	if(evt.keyCode == 13) topSearchClick();
}
//------------------------------------------------------------------------------------------------------
function topSearchClick(){
	var txtTopSeach = getElement("txtTopSeach");
	var searchQuery = trim(txtTopSeach.value);
	if(g_topSearchUpdated == false) searchQuery = "";
	var frmTopSearch = getElement("frmTopSearch");		
	
	frmTopSearch.searchquery.value = searchQuery;
	frmTopSearch.submit();
}
//=========================================== TOP SEARCH END===============================================

//=========================================== TOP LOGIN ================================================
function passwordStartMouseDown(obj){	
	document.getElementById("passwordStart").style.display = "none";
	document.getElementById("top_password").style.display = "";
	//document.getElementById("top_password").focus();
	setTimeout(function(){setPWDFocus();}, 50);
}
function setPWDFocus()
{
	document.getElementById("top_password").focus();
}
function passwordStartBlur(){
	var pass = document.getElementById("top_password");
	if(pass.value == ""){
		document.getElementById("passwordStart").style.display = "";		
		pass.style.display = "none";
	}
}
function topLoginKeyUp(obj,evt){
	if(jQuery(obj).attr('id')=='top_username'){
		g_topLoginUserUpdated = true;
	}
	if(jQuery(obj).attr('id')=='passwordStart'){
		g_topLoginPassUpdated = true;	
		jQuery("#passwordStart").css('display','none');
		jQuery("#top_password").css('display','').focus();
	}
	doOnEnter(evt,'topLoginClick');
}

//------------------------------------------------------------------------------------------------------
function topLoginFocus(obj){
	if(obj.value == "User name") obj.value = "";
}
function topPasswordBlur(obj){
	if(obj.value == "") obj.value = "Password";
}
function topLoginBlur(obj){
	if(obj.value == "") obj.value = "User name";
}
//=========================================== TOP LOGIN ================================================

/////////////////////////////////////// LOGIN FUNCTION ///////////////////////////////
//---------------------------------------------------------- Globals Login
var g_func = "<?php echo $this->layout()->incorrect?>";


function checkRememberMe()
{
	if(jQuery('#check_Rememberme').attr('checked')==true)
	{	
		jQuery('#rememberme').val('on'); 				
	}
	else
	{
		jQuery('#rememberme').val('off');			
	}
}
function loginClick(){
	var username = jQuery('#username').val();
	var password = jQuery('#password').val();
    jQuery('#txtUsername').val(username);
	jQuery('#txtPassword').val(password);	
	jQuery('#frm_login').submit();
}
function vipClick(){
	var  frmVIP = document.getElementById('frmVIP');
	frmVIP.securitycode.value = jQuery('#otp').val();
	frmVIP.submit();	
}
//-----------------------------------------------------------------
function topLoginClick(){
	var username = jQuery('#top_username').val();
	var password = jQuery('#top_password').val();
		
	var frmLogin = getElement("frm_login");
	
    jQuery('#txtUsername').val(username);
	jQuery('#txtPassword').val(password);
	
	if(username=='User name'){
		location.href=g_loginPath;
	}else{
		frmLogin.submit();
	}
}
//------------------------------------------------------------------------------------			
function initLogin(){    
    jQuery.noConflict(); 
    jQuery(document).ready(function (){       
       if(g_func == "1") jQuery('txtPassword').focus();
	   else jQuery('txtUsername').focus();
	   //pageAutosuggest();	  	
    });      
}	
//-------------------------------------------------------------------------------------
function rememberClick() {
	jQuery( '#frm_forgot' ).submit();
}
/////////////////////////////////////// END LOGIN /////////////////////////////////////
function closeMessage(msg)
{
	jQuery('div#'+msg).css('display','none');
}

/////////////////////////////////////// BEGIN RESET FORM //////////////////////////////
function clear_form_elements(ele) {	
	jQuery(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
            	jQuery(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}
/////////////////////////////////////// END RESET FORM //////////////////////////////////

/////////////////////////////////////// BEGIN DISPLAY ERROR LOADER //////////////////////
function displayError(response, errorType, errorThrown) {
	  try {
	    if(errorType == 'timeout'){	    	
	    	displayLoaderErrorMsg('timeout');
	    }else{
	    	displayLoaderErrorMsg();
	    }		
	    return (false);
	  }catch (e) {}
}
/////////////////////////////////////// END DISPLAY ERROR LOADER /////////////////////////
