/**
 * @author evams
 */
$().ready(function() {
	$("input[type='hidden']").css('display','none');
	$("table.striped tr:has(td):even").css("background-color", "#EAF8FF");
	$("#showform").click(function(){
		$("#formcontainer").css('display','block');
		$(this).css('display','none');
	});
    $("#search_form, #simplesearch_form").submit(function(){
            $("#WT\\.oss").val($("#q").val());
    });
    $(".aboutrosacea").click(function(){
    	aboutRosacea($(this).attr('href'));
    	return false;
    });

    
    $("#log").submit(function(event){
    	var credential_0=$("#credential_0").val();
    	var credential_1=$("#credential_1").val();
    	var mesg;
    	var err;

    	var submitok = true;
    	if ((credential_0== null) || (credential_0== "") || (credential_0.length==0)){ 
    		$("#emsg").css("paddingLeft","6px");
    		$("#emsg").html("Username can't be blank.");
    		$("#credential_0").focus();								
    		submitok = false;
    	}
    	if((credential_1== null) || (credential_1== "")){
    		$("#emsg").css("paddingLeft","6px");
    		$("#emsg").html("Password can't be blank.");	 
    		$("#credential_1").focus();								
    		submitok =  false;
    	}
		if(submitok){
	    	$.ajax({
				type: "POST",
				url: "/en/dbcheck.php",
				data: $(this).serialize(),
				async: false,
				success: function(msg){
					$(msg).each(function(i,el){
						if($(el).is(".message")){
							mesg = $(el).text() + '';
						}
						if($(el).is(".error")){
							err = $(el).text()+ '';
						}
					});
					if(mesg!=''){
			    		$("#emsg").css("paddingLeft","6px");
			    		$("#emsg").html(mesg);
//						alert('mesg');
			    		submitok =  false;
					}else{
//						alert('no mesg');
			    		submitok =  true;
	//					return true;
					}
	    		}
			});
		}
//		alert(event.result);
//		alert(submitok);
		return submitok;
    });
    $(".confirm").click(function(){
    	confirmation($(this).attr('href'));
    	return false;
    });
    $("a.register").click(function(){
    	$("#frmregister").submit();
    	return false;
    });
    $(".aboutfinacea").click(function(){
    	aboutFinacea($(this).attr('href'));
    	return false;
    });
    $(".howitworks").click(function(){
    	howItWorks($(this).attr('href'));
    	return false;
    });
    $(".caringskin").click(function(){
    	caringSkin($(this).attr('href'));
    	return false;
    });
    $(".watch").click(function(){
    	watch($(this).attr('href'));
    	return false;
    });
    $("#rstatus").click(function(){
    	showHideText();
    });


});


function confirmation(loc) {
	var answer = confirm("You are about to leave this Intendis, Inc. website by opening a new Web page. The site you are linking to is not controlled or endorsed by Intendis, Inc., and Intendis, Inc. is not responsible for its content.")
	if (answer==true){
		newwink= window.open(loc,'NewWindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left=0,top=0');
	}
}





function aboutFinacea(url) {		 
	if (browser == "Netscape") {
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=942&width=673&modal=true');
	    }
    else if((navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0)) {
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
    	}
   	else if((navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0)){
       	self.parent.tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
    }
    else{
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
    }
}



function howitWorks(url) {	
	if (browser == "Netscape") {
	  	self.parent.tb_open_new(url + '?TB_iframe=true&height=1213&width=680&modal=true');
    }
    else if((navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0)) {
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=1199&width=680&modal=true&scroll=auto');
    	}
   	else if((navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0)){
       	self.parent.tb_open_new(url + '?TB_iframe=true&height=1190&width=680&modal=true&scroll=auto');
    }
    else{
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=1199&width=680&modal=true&scroll=auto');
    }
}

function caringSkin(url) {		
	if (browser == "Netscape") {
     	self.parent.tb_open_new(url + '?TB_iframe=true&height=1585&width=680&modal=true');
    }
    else if((navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0)) {
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=1610&width=680&modal=true');
    	}
   	else if((navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0)){
       	self.parent.tb_open_new(url + '?TB_iframe=true&height=1593&width=680&modal=true');       	
    }
    else{
    	self.parent.tb_open_new(url + '?TB_iframe=true&height=1592&width=680&modal=true');
    }	
}

function watch(url){
	self.parent.tb_remove();
	parent.window.location=url;
}

function aboutRosacea(url) {
	if (browser == "Netscape") {
		tb_open_new(url + '?TB_iframe=true&height=942&width=673&modal=true');
	}else if((navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0)) {
		tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
	}else if((navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0)){
		tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
	}else{
		tb_open_new(url + '?TB_iframe=true&height=942&width=675&modal=true');
	}
}
function showHideText() 
{ 
	if($("#rstatus").is(":checked")){ 
		$('#finaceaPatients').css('display','block');
	} else { 
		$('#finaceaPatients').css('display','none');
	}  
} 

function dbCheck(){
	
}
	function SetFormControls(flag)
	{
		if(parseInt(flag)==1)
		{
			document.getElementById("frmLoginForm").style.display="none";
			document.getElementById("frmForgetPasword").style.display="block";
		}
		else if(parseInt(flag)==2)
		{
			document.getElementById("frmLoginForm").style.display="block";
			document.getElementById("frmForgetPasword").style.display="none";
		}
		
		
	}
	function ReserPass(){
	//alert('called');
	var uemail=document.getElementById("mail").value; 
	//alert(uemail) 
		if ((uemail == null) || (uemail == "")){ 
//		alert('null');
		document.getElementById("emsg1").style.paddingLeft="6px";
		document.getElementById("emsg1").innerHTML="Email can't be blank.";
		document.resetPass.resetemail.focus();								
	 	return false;
		} 
		return true;
	}	


