//$.ui.dialog.defaults.bgiframe = true;
/*
$(document).ready(function(){
				$('#fabrication_drpLanguage_wrapper').components({"name":"cumbobox1",
										"items":[
													{"text":"English","data":{"type":"a","href":en_link,"value":"en"},"active":false},
													{"text":"Arabic" ,"data":{"type":"a","href":ar_link,"value":"ar"},"active":true}
												]								 
																 });
				});
*/

    $(document).ready(function(){
			//$("#sendToFriendDialog").dialog({ modal: true ,resizable: false ,autoOpen: false });
			if($('.print').length)$('.print').click(function(){print_page();});
			
        }
    );
	

$.fn.extend({
	  buildTabs: function() {
		$(this).children('.tabs-container').children('.tab-links').children('a').each(function(index,element){
			if (index == 0){
				$(this).addClass($(this).attr('rel')+'-active');
				$(this).parent().parent().children("div.tab-content[rel='"+$(this).attr("rel")+"']").slideDown("slow",function(){$(this).toggleClass('active');});
			}
			$(this).click(function(){
								var rel = $(this).attr('rel');
								var me =$(this);
								if ($(this).attr('class') == rel+'active')return false;   
								//alert($(this).parent().parent().children("div.active").length );
								if ($(this).parent().parent().children("div.active").length > 0){
									$(this).parent().parent().children("div.active").slideUp("slow",function(){	
										var otherRel = $(this).attr('rel');										
										$(this).parent().children("div.tab-content[rel='"+rel+"']").slideDown('slow', function(){	
											$(me).parent().children('a.'+otherRel+'-active').removeClass(otherRel+'-active');	
											$(me).addClass(rel+'-active');
										}).toggleClass('active');
									 }).toggleClass('active');
								}else{
									//alert($(this).next("div.tab-content[rel='"+rel+"']").length);
									$(this).parent().children("div.tab-content[rel='"+rel+"']").slideDown('slow').toggleClass('active');	
								}
								
								return false;
							});
		});
	  }
});
			  
$.fn.extend({
	  tree_build: function() {
			if($(this).children('li').length){
				if($(this).children('li').children('span').length){

						$(this).children('li')
							.each(function(index,element){
									
									$(this).children('span').children('a').smooze();
								
			   						if($(this).children('ul').length){
										$(this).children('span').css({"border-bottom":"solid 2px #AEAEAE"});
										$(this).children('span').click(function(){
											$(this).next('ul:first').slideToggle("slow");
											//$(this).next('ul').hideTheOthers();
											$(this).next('ul').parent().toggleClass("active-folder");
											//return false;
										});		
										//$(this).children('span').click();
									}			
									
									if($(this).children('span').children('a').attr('class') == 'active-link'){
										element = $(this);
										//alert($(element).is("li"));
										while($(element).parent().is("ul")){
											$(element).children('span').click();
											element = $(element).parent().parent();
										}										
									}
								});
					
				}
			}
			//$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
	   
	  },
	  
	  smooze: function(){
		  var paddingLeft = $(this).css("padding-left");
		  var mouseoverEvent = $(this).mouseover;
		  $(this).mouseover(
							
							function(){	
										//$(this).mouseover=function(){return false};
									 	$(this).animate({paddingLeft:10}
									 , "slow",
									 function(){
										 $(this).animate({paddingLeft:paddingLeft});
		  								})
									 });

	  },
	  
	  hideTheOthers: function() {
		 //$(this).next('li').siblings().children('ul').slideUp("slow").toggleClass("active-folder");
	  }
});



// divisions

$.fn.extend({
	  toDivisionMenu: function() {
			if($(this).children('li').length){
				if($(this).children('li').children('a').length){

						$(this).children('li')
							.each(function(index,element){
									
									$(this).children('a').smoze();								
								
			   						if($(this).children('ul').length){
										//$(this).children('ul').tree_build();
										$(this).click(function(){
											$(this).children('ul').slideToggle(300);
											$(this).toggleClass("active-folder");
										});		
									}						
								});
					
				}
			}
			//$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
	   
	  },
	  
	  smoze: function(){
		  var marginLeft = $(this).css("margin-left");
		  var mouseoverEvent = $(this).mouseover;
		  $(this).mouseover(
							
							function(){	
										$(this).toggleClass("active");
										//$(this).mouseover=function(){return false};
									 	$(this).animate({marginLeft:20}
									 , "slow",
									 function(){
										 $(this).animate({marginLeft:marginLeft});
		  								})
									 });
		  
			$(this).mouseout(function(){	$(this).toggleClass("active");});
	  }
});

		
				

	/*	function showLogin() {
		
	        		$(function(){
					
							$('#sendToFriendDialog').dialog({
											autoOpen: false,
											width: 200
											
										});
					});
					$("#sendToFriendDialog").dialog('open');
		}
*/
		function showLogin() {
		$("#sendToFriendDialog").dialog('open');
	}	
		
		/*
function Sendtofriend(){
		//	alert('I AM INSIDE THE FUNCTIONS ') ;
			$("#frm_sendtofriend").find("[name=friendMail],[name=submit]").attr('disabled',true);
			$('#sendToFriendDialogMessageFailure,#sendToFriendDialogMessagesuccess').hide();
			$('#sendToFriendDialogLoader').hide();
					$.ajax({
					url: "index.php?pg=sendtofriend&disable_rewrite=1&plain=1",
					type:"POST",
					async: true,
					dataType:'json',
					data: {
						friendMail:$("#frm_sendtofriend").find("[name=friendMail]").val()//,
						//cur_url:$("#frm_sendtofriend").find("[name=cur_url]").val()
					},
					beforeSend: function(XMLHttpRequest) {
					},
					success: function(json){
								if(json.err) {
								    $('#sendToFriendDialogMessageFailure').html(json.msg).show();
								}else{
									$('#sendToFriendDialogMessagesuccess').html(json.msg).show();
								}
								//alert('success') ;
								$('#sendToFriendDialogLoader').hide();
								$("#frm_sendtofriend").find("[name=friendMail],[name=submit]").attr('disabled',false);	
						
								if(!json.err) {
									alert(document.location.href);
									//window.location.href=document.location.href;//$("#frm_sendtofriend").find("[name=cur_url]").val();
								}
						
					
					},
					error: function (XMLHttpRequest, textStatus, errorThrown) {
						alert('Server Error') ;
						$('#sendToFriendDialogLoader').hide();
						$("#frm_sendtofriend").find("[name=friendMail],[name=submit]").attr('disabled',false);
					}
				});
		}
	*/	
		function printdiv(printpage)
		{
			var headstr = "<html><head><title></title></head><body><table width=800><tr><td>";
			var footstr = "</td></tr></table></body>";
			var newstr = document.getElementById(printpage).innerHTML;
			var oldstr = document.body.innerHTML;
			document.body.innerHTML = headstr+newstr+footstr;
			window.print(); 
			document.body.innerHTML = oldstr;
			return false;
		}

	
	
	
	
	var animateMethod = '';
	$.fn.extend({
		  animateBanner: function(up) {
				if($(this).children('img').length){
					var activeContainer = $(this);					
					 //alert(up);

					
					
					$(this).children('.buttons').children('.back').click(function(){
																clearInterval(animateMethod);
																$(activeContainer).move(false);
																$(activeContainer).start(false);
																return false;
															 });
					$(this).children('.buttons').children('.next').click(function(){
																clearInterval(animateMethod);
																$(activeContainer).move(true);
															 	$(activeContainer).start(true);
																return false;
															 });		
					$(this).start(true);
/*
					if (r){
							animateMethod = setInterval(function(){	
											activeContainer.moveRight();
										 },5000);
					}else{
							animateMethod = setInterval(function(){	
											activeContainer.moveLeft();
										 },5000);
					}
					
					*/
					
				}
				
		  },
		  
		  start: function (up){
			  	var activeContainer = $(this);
				if ($(this).children('img').length > 1){
					animateMethod = setInterval(function(up){
														$(activeContainer).move(up);						//alert(up);
													},5000,up);  
				}
		  },
		  
		  move : function(up){
				var $img 	= $(this).children('img.active').length ? $(this).children('img.active') : $(this).children('img:first');
				var $nextImg = up ? ($($img).next('img').length ? $($img).next('img') : $($img).parent().children('img:first')) : ($img.prev('img').length ? $img.prev('img') : $img.parent().children('img:last'));
							
				$img.css({'z-index':1}).fadeOut(2000,function(){$(this).toggleClass('active')});
				$nextImg.css({'z-index':0}).toggleClass('active').fadeIn(2000);
		  },
		  
		  moveLeft : function(){
			  
			  		var $img 	= $(this).children('img.active');
					var $nextImg= $($img).next('img').length ? $($img).next('img') : $($img).parent().children('img:first');
					$img.animate({left: -$img.outerWidth() },function(){$(this).toggleClass('active');})
					$nextImg.css({left: $img.outerWidth() }).toggleClass('active').animate({left: 0 });	
		  },
		  
		  moveRight : function(){
				  	var $img 	= $(this).children('img.active');
					var $nextImg = $img.prev('img').length ? $img.prev('img') : $img.parent().children('img:last');
					$img.animate({marginLeft: $img.outerWidth() },function(){$(this).toggleClass('active');})
					$nextImg.css({marginLeft: -$nextImg.outerWidth() }).toggleClass('active').animate({marginLeft: 0 });			  
		  }
		  
	});

	
 $.fn.extend({
			 buildProductsNav:function(){
				$(this).children('ul').children('li').each(
					function(index,element){							//alert($(this).attr('class'));
										$(this).children('a').click(function(){return false;});
										$(this).click(
												function(){
													var active = $(this).parent().children('li.active').toggleClass('active');
													$(this).toggleClass('active');
												}
											);
										
					});
			 }
			 
			 
		});
 
 

 var hasBlur = false; 
 function enable(id,value){
 var child;
 var height;
 
 Date.format = 'yyyy/mm/dd';
 
			  if(value==1 || value=='true'){
				    document.getElementById(id).disabled = false ;
				 
							
							if(!hasBlur && id == 'children_no'){

								$("#"+id).change(function(){
											child=parseInt(document.getElementById(id).value);
											 $("#children_div").html('');
										   for(var i=1;i<=child;i++){
											  $("#children_div").append("<tr><td>Child "+i+"----></td><td>Name<input size='15' type='text' name='child_name[]' id='child_name_"+i+"' ></td><td >DOB</td><td><input type='text' name='child_dob[]' id='child_dob_"+i+"'></td></tr>");
											  
											      $("#child_dob_"+i).datePicker({startDate:'1930/1/1'});
											}
											
								   //height = parseInt($('#PrintableDivContent').height())+(child*7);
								  // $('#PrintableDivContent').css('height',height+'px');
								  
								   $('#section').jScrollPane();			
								});

									 hasBlur = true;
							}
					
			   }else if(value==0 || value=='false'){
				 document.getElementById(id).value='';
				 document.getElementById(id).disabled = true ;
				 
				     if(id == 'children_no'){
				         $("#children_div tr").remove();
						 
                           $('#section').jScrollPane();						 
					  }
			  }
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789+";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
       return IsNumber;
   
}

function OnlyNumbers(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
       return IsNumber;
   
}  

function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.getElementById(email).value;
   if(reg.test(address) == false) {
      return false;
   }
}

function formValidationOutside(){
	 var checkedCount = 0 ;
	 var title        = $("#title").val(); 
     var fname        = $("#fname").val(); 
     var lname        = $("#lname").val(); 
     var country_id   = $("#country_id").val(); 
	 var nationality  = $("#nationality").val(); 
     var phone        = $("#phone").val();  
	 var useremail    = $("#useremail").val();
	 var address      = $("#address").val();
	 

	  if(title == null || title == ''){
	   alert('please choose your title') ;
	    $("#title").focus();
	   return false ;
	 }
	 if(fname == null || fname == ''){
	   alert('please enter your first name') ;
	    $("#fname").focus();
	   return false ;
	 }
	  else if(lname == null || lname == ''){
	   alert('please enter your last name') ;
	    $("#lname").focus();
	    return false ;
	 }
	 else if(country_id == 0 || country_id == ''){
	   alert('please select your country') ;
	    $("#country_id").focus();
	   return false ; 
	 }
	  else if(nationality == 0 || nationality == ''){
	   alert('please select your nationality') ;
	    $("#nationality").focus();
	   return false ; 
	 }
	 /*
	  if(address == null || address == ''){
	   alert('please enter your address') ;
	    $("#address").focus();
	   return false ;
	 }*/
	  else if(useremail == null || useremail == ''){
	   alert('please enter your e-mail address') ;
	    $("#useremail").focus();
	    return false ;
		
	 }
	 else if (validateEmail("useremail") ==false) 
     { 
         alert('Invalid Email Address');
		 $("#useremail").focus();
	    return false ;
     }
	 else if(phone == null || phone == ''){
	   alert('please enter your phone number') ;
	   $("#phone").focus();
	    return false ;
		
	 }
	 else if (IsNumeric(phone) ==false) 
     { 
        alert('please enter a valid phone number') ;
		$("#phone").focus();
	    return false ;
     }
	
	 else if(document.getElementById('enfants_no').disabled == true && document.getElementById('children_no').disabled == true && document.getElementById('adults_no').disabled == true /* && document.getElementById('seniors_no').disabled == true */ ){
	   alert('You have to enter the number of people ') ;
	   $("#enfants_no").focus();
	      return false ; 
	}
	 else if(document.getElementById('enfants_no').disabled == false)
	 {
		if(document.getElementById('enfants_no').value == '' || IsNumeric(document.getElementById('enfants_no').value) ==false)
		{ 
		  $("#enfants_no").focus();
	      alert('please enter a valid enfants number') ;
	      return false ;
		}
	 }
		if(document.getElementById('children_no').disabled==false){
		   if(document.getElementById('children_no').value=='' || OnlyNumbers(document.getElementById('children_no').value) ==false){
			  $("#children_no").focus(); 
			 alert('please enter a valid childrennumber') ;
			  return false ;
		  }
		}
		
		if(document.getElementById('adults_no').disabled==false){
		   if(document.getElementById('adults_no').value=='' || OnlyNumbers(document.getElementById('adults_no').value) ==false){
			 $("#adults_no").focus();
			 alert('please enter a valid adults number') ;
			  return false ;
		  }
		}
	/*	if(document.getElementById('seniors_no').disabled==false){
		   if(document.getElementById('seniors_no').value=='' || OnlyNumbers(document.getElementById('seniors_no').value) ==false){
			 alert('please enter a valid seniors number') ;
			  return false ;
		  }
		} */


  var checkedCount = 0 ;
	$(".chk").each(function() {
		   if (this.checked) {
			  checkedCount++;
		   }
	});
//	alert(checkedCount)
	if(checkedCount== 0 && $(".chk").length > 0){
		alert('please select your favourite places') ;
		return false;
	}
	if(!document.getElementById('3s').checked && !document.getElementById('4s').checked && !document.getElementById('5s').checked){
			 alert('please enter your price range accomodation') ;
			  $("#3s").focus();
			 return false;
     }
	if(!document.getElementById('single').checked && !document.getElementById('double').checked && !document.getElementById('triple').checked & !document.getElementById('quad').checked){
			 alert('please enter your room type') ;
			 $("#single").focus();
			 return false;
     }
	 if(!document.getElementById('bb').checked && !document.getElementById('breakfast').checked && !document.getElementById('half').checked && !document.getElementById('full').checked && !document.getElementById('bedandbreakfast').checked ){
			 alert('please enter your Meal Plan') ;
			 $("#3s").focus();
			 return false;
     }
    if(document.getElementById('from').value==''){
			 alert('please enter the data do you want to start ') ;
			 $("#3s").focus();
			 return false;
     }
   if(document.getElementById('to').value==''){
			 alert('please enter the data do you want to get back ') ;
			 $("#3s").focus();
			 return false;
     }
	 if(document.getElementById('no_of_days').value==''){
			 alert('please enter how many days do you want to stay') ;
			 $("#3s").focus();
			 return false;
     }
	 
	 return true ;
	
}



function formValidationRequestMice(){
	
     var company    = $("#company").val(); 
     var fname      = $("#fname").val(); 
     var surname    = $("#surname").val(); 
	 var job        = $("#job").val(); 
	 var phone      = $("#phone").val(); 
     var address    = $("#address").val();  
	 var useremail  = $("#useremail").val(); 
	 var from       =  $("#from").val(); 
	 var to         =  $("#to").val(); 
	 var title      = $("#title").val(); 
	 
	 if(title == null || title == ''){
	   alert('please choose your title') ;
	    $("#title").focus();
	   return false ;
	 }
	 if(company == null || company == ''){
	   alert('please enter your company name') ;
	    $("#company").focus();
	   return false ;
	 }
	  else if(fname == null || fname == ''){
	   alert('please enter your first name') ;
	    $("#fname").focus();
	    return false ;
	 } 
	  else if(surname == null || surname == ''){
	   alert('please enter your surname') ;
	    $("#surname").focus();
	    return false ;
	 }
	  else if(job == null || job == ''){
	   alert('please enter your job title') ;
	    $("#job").focus();
	    return false ;
	 }
	  else if(address == null || address == ''){
	   alert('please enter your company address') ;
	    $("#address").focus();
	    return false ;
	 }
	  else if(phone == null || phone == ''){
	   alert('please enter your phone number') ;
	   $("#phone").focus();
	    return false ;
		
	 }
	 else if (IsNumeric(phone) ==false) 
     { 
        alert('please enter a valid phone number') ;
		$("#phone").focus();
	    return false ;
     }
	   else if(useremail == null || useremail == ''){
	   alert('please enter your e-mail address') ;
	    $("#useremail").focus();
	    return false ;
		
	 }
	 else if (validateEmail("useremail") ==false) 
     { 
         alert('Invalid Email Address');
		 $("#useremail").focus();
	    return false ;
     }
	
	 else if(from == null || from == ''){
	   alert('please enter your start date') ;
	   $("#from").focus();
	    return false ;
		
	 }
	  else if(to == null || to == ''){
	   alert('please enter your end date') ;
	   $("#to").focus();
	    return false ;
		
	 }
 var checkedCount = 0 ;

	$(".equip").each(function() {
		   if (this.checked) {
               var name = $(this).attr('id')+'_no' 
              if(! IsNumeric($('#'+name).val()) || $('#'+name).val() == '' ){
                checkedCount++;          
               }
            }
	});
	if(checkedCount > 0 ){
		alert('please write a valid numbers for the equipments') ;
		return false;
	}
		
		
		
	
}
function formValidation(){
	
	 var checkedCount = 0 ;
	 var title        = $("#title").val(); 
     var fname        = $("#fname").val(); 
     var lname        = $("#lname").val(); 
     var country_id   = $("#country_id").val(); 
	 var nationality  = $("#nationality").val(); 
     var phone        = $("#phone").val(); 
	 var mobile       = $("#mobile").val(); 
	 var useremail    = $("#useremail").val();
	 var address      = $("#address").val();
	 

	  if(title == null || title == ''){
	   alert('please choose your title') ;
	    $("#title").focus();
	   return false ;
	 }
	 else if(fname == null || fname == ''){
	   alert('please enter your first name') ;
	    $("#fname").focus();
	   return false ;
	 }
	  else if(lname == null || lname == ''){
	   alert('please enter your last name') ;
	    $("#lname").focus();
	    return false ;
	 }
	 else if(country_id == 0 || country_id == ''){
	   alert('please select your country') ;
	    $("#country_id").focus();
	   return false ; 
	 }
	  else if(nationality == 0 || nationality == ''){
	   alert('please select your nationality') ;
	    $("#nationality").focus();
	   return false ; 
	 }
	  /*
	  if(address == null || address == ''){
	   alert('please enter your address') ;
	    $("#address").focus();
	   return false ;
	 }
	 */
	  else if(useremail == null || useremail == ''){
	   alert('please enter your e-mail address') ;
	    $("#useremail").focus();
	    return false ;
		
	 }
	 else if (validateEmail("useremail") ==false) 
     { 
         alert('Invalid Email Address');
		 $("#useremail").focus();
	    return false ;
     }
	 else if(phone == null || phone == ''){
	   alert('please enter your phone number') ;
	   $("#phone").focus();
	    return false ;
		
	 }
	  else if(mobile == null || mobile == ''){
	   alert('please enter your mobile number') ;
	   $("#mobile").focus();
	    return false ;
		
	 }
	 else if (IsNumeric(phone) ==false) 
     { 
        alert('please enter a valid phone number') ;
		$("#phone").focus();
	    return false ;
     }
	

	/////////////////////
	 else if(document.getElementById('enfants_no').disabled == true && document.getElementById('children_no').disabled == true && document.getElementById('adults_no').disabled == true /* && document.getElementById('seniors_no').disabled == true */ ){
	   alert('You have to enter the number of people ') ;
	   $("#enfants_no").focus();
	      return false ; 
	}
	 else if(document.getElementById('enfants_no').disabled == false)
	 {
		if(document.getElementById('enfants_no').value == '' || IsNumeric(document.getElementById('enfants_no').value) ==false)
		{ 
		  $("#enfants_no").focus();
	      alert('please enter a valid enfants number') ;
	      return false ;
		}
	 }
		if(document.getElementById('children_no').disabled==false){
		   if(document.getElementById('children_no').value=='' || OnlyNumbers(document.getElementById('children_no').value) ==false){
			  $("#children_no").focus(); 
			 alert('please enter a valid childrennumber') ;
			  return false ;
		  }
		}
		
		if(document.getElementById('adults_no').disabled==false){
		   if(document.getElementById('adults_no').value=='' || OnlyNumbers(document.getElementById('adults_no').value) ==false){
			 $("#adults_no").focus();
			 alert('please enter a valid adults number') ;
			  return false ;
		  }
		}
	/*	if(document.getElementById('seniors_no').disabled==false){
		   if(document.getElementById('seniors_no').value=='' || OnlyNumbers(document.getElementById('seniors_no').value) ==false){
			 alert('please enter a valid seniors number') ;
			  return false ;
		  }
		} */


  var checkedCount = 0 ;
	$(".chk").each(function() {
		   if (this.checked) {
			  checkedCount++;
		   }
	});
//	alert(checkedCount)
	if(checkedCount== 0 && $(".chk").length > 0){
		alert('please select your favourite places') ;
		return false;
	}
	if(!document.getElementById('3s').checked && !document.getElementById('4s').checked && !document.getElementById('5s').checked  && !document.getElementById('oth').checked){
			 alert('please enter your price range accomodation') ;
			  $("#3s").focus();
			 return false;
     }
	if(!document.getElementById('single').checked && !document.getElementById('double').checked && !document.getElementById('triple').checked){
			 alert('please enter your room type') ;
			 $("#single").focus();
			 return false;
     }
	 if(!document.getElementById('bb').checked && !document.getElementById('breakfast').checked  && !document.getElementById('half').checked && !document.getElementById('full').checked && !document.getElementById('hardinc').checked && !document.getElementById('softinc').checked){
			 alert('please enter your Meal Plan') ;
			 $("#3s").focus();
			 return false;
     }
    if(document.getElementById('from').value==''){
			 alert('please enter the data do you want to start ') ;
			 $("#3s").focus();
			 return false;
     }
   if(document.getElementById('to').value==''){
			 alert('please enter the data do you want to get back ') ;
			 $("#3s").focus();
			 return false;
     }
	 if(document.getElementById('no_of_days').value==''){
			 alert('please enter how many days do you want to stay') ;
			 $("#3s").focus();
			 return false;
     }
	 
	 return true ;

}



///////////////

function formValidationMedical(){
	
	 var title        = $("#title").val(); 
     var fname        = $("#fname").val(); 
     var lname        = $("#lname").val(); 
     var country      = $("#country").val(); 
     var phone        = $("#phone").val(); 
	 var mobile       = $("#mobile").val(); 
	 var useremail    = $("#useremail").val();
	 var address      = $("#address").val();
	 var tdate        = $("#tdate").val();
	 var city        = $("#city").val();
	 var sec_no        = $("#sec_no").val();

    /////////////////////
	
	 if(tdate == null || tdate == ''){
	   alert('please choose date') ;
	    $("#tdate").focus();
	   return false ;
	 }
	 

	  else if(title == null || title == ''){
	   alert('please choose your title') ;
	    $("#title").focus();
	   return false ;
	 }
	 else if(fname == null || fname == ''){
	   alert('please enter your first name') ;
	    $("#fname").focus();
	   return false ;
	 }
	  else if(lname == null || lname == ''){
	   alert('please enter your last name') ;
	    $("#lname").focus();
	    return false ;
	 }
	 else if(country == null || country == ''){
	   alert('please select your country') ;
	    $("#country").focus();
	   return false ; 
	 }
	else if(city == null || city == ''){
	   alert('please city is required') ;
	    $("#city").focus();
	   return false ; 
	 }

	 else if(sec_no == null || sec_no == ''){
	   alert('please enter your Sec.Soc.No') ;
	    $("#sec_no").focus();
	   return false ;
	 }
	 
	  else if(address == null || address == ''){
	   alert('please enter your address') ;
	    $("#address").focus();
	   return false ;
	 }
	  else if(useremail == null || useremail == ''){
	   alert('please enter your e-mail address') ;
	    $("#useremail").focus();
	    return false ;
		
	 }
	 else if (validateEmail("useremail") ==false) 
     { 
         alert('Invalid Email Address');
		 $("#useremail").focus();
	    return false ;
     }
	 else if(phone == null || phone == ''){
	   alert('please enter your phone number') ;
	   $("#phone").focus();
	    return false ;
		
	 }
	  else if(mobile == null || mobile == ''){
	   alert('please enter your mobile number') ;
	   $("#mobile").focus();
	    return false ;
		
	 }
	 else if (IsNumeric(phone) ==false) 
     { 
        alert('please enter a valid phone number') ;
		$("#phone").focus();
	    return false ;
     }
	
	
	if(!document.getElementById('female').checked && !document.getElementById('male').checked ){
			 alert('please chose your sex') ;
			  $("#male").focus();
			 return false;
     }
	if(!document.getElementById('single').checked && !document.getElementById('married').checked && !document.getElementById('triple').checked && !document.getElementById('widowed').checked && !document.getElementById('separated').checked && !document.getElementById('divorced').checked){
			 alert('please enter your marital status') ;
			 $("#single").focus();
			 return false;
     }

	
	return true;
}
	//////////////


function print_page(){
		
				var disp_setting= "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=900, height=900, left=0, top=0"; 
				var content_value= $('#PrintableDiv').html(); 
				var docprint=window.open("","",disp_setting); 
				docprint.document.open(); 
				docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Karnak </title><link rel="stylesheet" type="text/css" href="'+g_templatepath+'/cdn/css/styles.css" media="all" />');				
				docprint.document.write('</head><body onLoad="self.print()" style="margin:20px 20px 20px 20px;"><center><div><div style="width:100%;margin-left:0px; clear:left;float:left;"><img src="'+g_templatepath+'/cdn/images/798.png" align="left"/></div><div style="clear:left;float:left;">');          
				docprint.document.write('<table class="print-page"><thead></thead><tfoot valign="bottom" ></tfoot><tbody><tr><td class="page-tbody-container">'+content_value+'</td></tr></tbody></table></div>');          
				docprint.document.write('</div></center></body></html>'); 
				 
				docprint.focus(); 
				docprint.document.close();
		
		/*	var headstr = "<html><head><title></title></head><body>";
			var footstr = "</body>";
			var newstr = document.getElementById('print-div').innerHTML;
			var oldstr = document.body.innerHTML;
			document.body.innerHTML = headstr+newstr+footstr;
			window.print(); 
			document.body.innerHTML = oldstr;
			return false;*/
		}
		
		//////////
		
		
//	function showfriend() {
//		$("#sendToFriendDialog").dialog('open');
//	}	
		
		
		
//Dialog 

/*
  $(function() {
        $("#contact").live('click', function(event) {
            $(this).addClass("selected").parent().append('<div class="messagepop pop"><form method="post" id="new_message" action="/messages"><p><label for="email">Your email or name</label><input type="text" size="30" name="email" id="email" /></p><p><label for="body">Message</label><textarea rows="6" name="body" id="body" cols="35"></textarea></p><p><input type="submit" value="Send Message" name="commit" id="message_submit"/> or <a class="close" href="/">Cancel</a></p></form></div>');
            $(".pop").slideFadeToggle()
            $("#email").focus();
            return false;
        });

        $(".close").live('click', function() {
            $(".pop").slideFadeToggle();
            $("#contact").removeClass("selected");
            return false;
        });
    });

    $.fn.slideFadeToggle = function(easing, callback) {
        return this.animate({ opacity: 'toggle', height: 'toggle' }, "fast", easing, callback);
    };

*/

 $(document).ready(function () {  
   
     // if user clicked on button, the overlay layer or the dialogbox, close the dialog    
     $('#dialog-overlay').click(function () {       
         $('#dialog-overlay, #dialog-box').hide();         
         return false;  
     });  
       
     // if user resize the window, call the same function again  
     // to make sure the overlay fills the screen and dialogbox aligned to center      
     $(window).resize(function () {  
           
         //only do it if the dialog box is not hidden  
         if (!$('#dialog-box').is(':hidden')) popup();  
		  $('.send-to-friend').click(function(){popup();});  
     });   
       
       
 });  
   
 function closeWin(){
	  $('#dialog-box ,#dialog-overlay').hide(); 
 }

 //Popup dialog  
 function popup() {  
     // get the screen height and width    
     var maskHeight = $(document).height();    
     var maskWidth = $(window).width();  
       
     // calculate the values for center alignment  
     var dialogTop =  (maskHeight/3) - ($('#dialog-box').height());    
     var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);   
	 
    // assign values to the overlay and dialog box  
     $('#dialog-overlay').css({height:maskHeight, width:maskWidth}).show();  
     $('#dialog-box').css({top:dialogTop, left:dialogLeft}).show();  
       
     // display the message  
     $('#dialog-message').html('<h1 align="center" style="clear:both;">Send to friend'+
							   '<a href="javascript:return false" onclick="closeWin()">'+
					           '<img src="'+g_templatepath+'/cdn/images/closeWin.png" align="right" />&nbsp;</a>'+
							   '</h1>'+
							   '<form name="frm_sendtofriend" id="frm_sendtofriend" method="POST" onSubmit="Sendtofriend();return false;" >'+
							   '<p style="clear:both;">'+
							   '<label>Friend email</label><input type="text" name="friendMail" width="10px"  />'+
							   '</p>'+
							   '<p>'+
							   '<label>Your email</label><input type="text" name="userMail"  />'+
							   '</p>'+
							   '<p>'+
							   '<input type="submit" name="submit" value="submit" class="button"/>'+
							   '</p>'+
							   '<br />'+
                               '<span id="sendToFriendDialogLoader"><img src="{$g_smarty_templatepath}/images/preloaders/load1.gif"></span>'+
							   '<div id="sendToFriendDialogMessageFailure"></div>'+
                               '<div id="sendToFriendDialogMessagesuccess"></div>'); 
	 
 } 
