// function need by flash 
 function GroupDelegate(id) {
	 var objLink = document.getElementById(id);
	 Lightbox.prototype.start(objLink);
}

 
 // email validation function 
  function validateEmail(eValue){  
    var reg =/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
    return reg.test(eValue);  
 }  




// form related functions 

jQuery.noConflict();



function showOnClick(id){
	count=id;
	
	//document.getElementById('tmpSlideshowControl_'+count).className='tmpSlideshowControlActive';
	
	for(var i=1; i<=total_image;i++){
		
		
			if(i!=id){
				if(jQuery("#tmpSlideshowControl_"+i).attr("class")=="tmpSlideshowControlActive"){
					
					jQuery("#tmpSlide_"+i).fadeOut(500);	
					jQuery("#tmpSlideshowControl_"+i).addClass('tmpSlideshowControl').removeClass("tmpSlideshowControlActive");	
						
					
					
				}
			}
			else{
				
				jQuery("#tmpSlide_"+i).fadeIn();
				jQuery('#tmpSlideshowControl_'+i).addClass('tmpSlideshowControlActive').removeClass("tmpSlideshowControl");
			
			}
		
		next=(id==total_image)?1:id+1;
	}
	
	
	
	
	/*
	if(next){
		jQuery("#tmpSlide_"+next).fadeOut(500,function(){		
			jQuery("#tmpSlide_"+count).fadeIn();
			document.getElementById('tmpSlideshowControl_'+next).className='tmpSlideshowControl';
		});
	}
	else{
		document.getElementById('tmpSlideshowControl_'+count).className='tmpSlideshowControlActive';
		jQuery("#tmpSlide_"+count).fadeIn();
	}*/
	
	
	
	/*
	if(jQuery('#tmpSlideshowControl_'+count).attr("lnk")!="#;"){
		location.href=	jQuery('#tmpSlideshowControl_'+count).attr("lnk");
	}*/
	
	
}


(function($) { 
  $(function() {
			
			if(jQuery(".tmpSlideshowControlActive").length){
			
				setinterval=setInterval("animateImage()", 6000);
			}
			
			// REgistration form validation 
			
		$("#registerMe").click(function(){
		
			
			var error =0;
			
			$(".err").empty().hide();
				
			if($("#email_address").val()=="")
			{
				
				$("#email_address_err").html("Please enter email address").show();
				error =1;
			}
			
			else if($("#email_address").val())
			{
				if(validateEmail($("#email_address").val() ) ==false){
					$("#email_address_err").html("Please enter correct email address").show();
					error =1;
				}
				
			}
			
			if($("#password").val()=="")
			{
				$("#password_err").html("Please enter password").show();
				error =1;
			}
			else if(parseInt($("#password").val().length) < 6)
			{
				$("#password_err").html("Password should be atleast 6 char long.").show();
				error =1;
			}
			else if($("#password").val()!="" && $("#rePassword").val()!="")
			{
				if($("#password").val() != $("#rePassword").val()){
					
					$("#password_err").html("Password and re-enter password are not same.").show();
					error =1;
				}
			}
			
			if($("#rePassword").val()=="")
			{
				$("#repassword_err").html("Please re-enter password").show();
				error =1;
			}
			
			if($("#forename").val()=="")
			{
				$("#forename_err").html("Plase enter your forename").show();
				error =1;
			}
			
			if($("#surname").val()=="")
			{
				$("#surname_err").html("Please enter your surname").show();
				error =1;
			}
			
			if($("#address").val()=="")
			{
				$("#address_err").html("Please enter your address").show();
				error =1;
			}
			
			if($("#country").val()=="0")
			{
				$("#country_err").html("Please select a country").show();
				error =1;
			}
			
			if($("#postal_code").val()=="")
			{
				$("#postal_code_err").html("Please enter your postal/zip code").show();
				error =1;
			}
			
			if($("#telephone").val()=="")
			{
				$("#telephone_err").html("Please enter your telephone number").show();
				error =1;
			}
			
			if($("#know_me_from").val()=="0")
			{
				$("#know_me_from_err").html("Please say where did you learn about us?").show();
				error =1;
			}
			
			
		
			if(error ==1){
				return false;	
			}
			else
			{
				$("#myForm").submit();
				return true;
			}
		})


	$("#email_address").blur( function() {
		
		// check email address exists or not 
		
		if($("#email_address").val()!="" && validateEmail($("#email_address").val())){
			
			$.ajax({
				  type: "GET",
				  url: "ajax.php",
				  data: "param=email_chk&email_address="+$("#email_address").val(),
				  success: function(msg){
					if($.trim(msg)){
						$("#email_address_err").html(msg).show();
					}
				  }
				});
			
		}
	
	});
	// email address blur function end here
	
	// Login form validation // 
 
	$("#loginButton").click(function(){
	 
		var error =0;
			
			$(".err").empty().hide();
				
			if($("#login_email_address").val()=="")
			{
				
				$("#email_address_err").html("Please enter login email id").show();
				error =1;
			}
			
			else if($("#login_email_address").val())
			{
				if(validateEmail($("#login_email_address").val() ) ==false){
					$("#email_address_err").html("Please enter correct email address").show();
					error =1;
				}
				
			}
			
			if($("#password").val()=="")
			{
				$("#password_err").html("Please enter password").show();
				error =1;
			}
		 
		 if(error==1)
		 {
			 return false;
		}
		else
		{
			$("#loginFrm").submit();
			return true;
		}
	 
	 });

	// login page function end here //
	
	$("#sendPass").click(function(){
	 
		//alert("asdf");
		
		var error =0;
			
			$(".err").empty().hide();
				
			if($("#log_email_address").val()=="")
			{
				
				$("#email_address_err").html("Please enter your email id").show();
				error =1;
			}
			
			else if($("#log_email_address").val())
			{
				if(validateEmail($("#log_email_address").val() ) ==false){
					$("#email_address_err").html("Please enter correct email address").show();
					error =1;
				}
			}
			
			if(error ==1)
			{
			  return false;		
			}
			else
			{
				$("#forgetFrm").submit();
				return true;
			}
		});
	


  });
  
  
  
  
  
  
  
  
  
})(jQuery);

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}



