	/***************************/
//@Author: Junior Joanis
//@website: www.twitter/juniorjoanis
//@email:junior.joanis@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/




//loading popup with jQuery magic!
function loadPopups(popname){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$(popname).fadeIn("slow");
		 popupStatus1 = 1;
}

//disable the Popups
function disablePopups(popname){
		$("#backgroundPopup").fadeOut("slow");
		$(popname).fadeOut("slow");		
}

//centering popup
function centerPopups(popname){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(popname).height();
	var popupWidth = $(popname).width();
	var left= windowWidth/4;
	//var left=windowWidth/2-popupWidth/2;
	//centering
	 if(popname =='#dealPicture'){
		 var top= getTop(document.getElementById('large_photo'));
			$(popname).css({
				"position": "absolute",
				"top": top,
				"left": left
			});	
	}else if(popname =='#popupContact4' ){
		 var top= getTop(document.getElementById('Share_button_email'));
			$(popname).css({
				"position": "absolute",
				"top": top - popupHeight/2,
				"left":windowWidth/2-500
			});	
	}else if(popname =='#contactus'){		 
		$(popname).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2,
			"left":windowWidth/2- ($(popname).width()) /2
		});
	}else if (popname=='#popupContact2'){
		$(popname).css({
				"position": "absolute",
				"top": windowHeight/2-popupHeight/2,
				"left":windowWidth/2-500
			});	
	
	}else if ( popname=="#developerpopup"){
		$(popname).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2,
			"left":windowWidth/2- ($(popname).width()) /2
		});
	}else{
		$(popname).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2,
			"left": left
	
		});
	}
	//only need force for IE6
	
	
		$("#backgroundPopup").css({
			"height": windowHeight
		});
	
}
//get the Left position of the HTML object
function getLeft(MyObject){
  //Fonction permettant de connaÃ®tre la position d'un objet
//par rapport au bord gauche de la page.
//Cet objet peut Ãªtre Ã  l'intÃ©rieur d'un autre objet.
  if (MyObject.offsetParent)
      return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
  else 
      return (MyObject.offsetLeft);
  }	
  
function getTop(MyObject){
//Fonction permettant de connaÃ®tre la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut Ãªtre Ã  l'intÃ©rieur d'un autre objet.
  
  if (MyObject.offsetParent)
      return (MyObject.offsetTop + getTop(MyObject.offsetParent));
  else
      return (MyObject.offsetTop);
 }

 //display the deals map popup

function popDealMap(content){
	
	/*var left=getLeft(document.getElementById("map"))/5;
	var y=getTop(document.getElementById("map"));
	var top=y + ($("#map").height() - $("#popupdealmap").height()) -20;*/
	//var top=y+25;
	//alert(bottom+left);
	var mapcontent = document.getElementById("popupdealmapContent");
	mapcontent.innerHTML = content;
	//loads popup only if it is disabled
		$("#popupdealmap").fadeIn("slow");
	
	if(navigator.platform =="MacIntel"){ //test if your Operating System is Mac OS 
		 
			 if($.browser.msie){	//jquery condition to test if the browser is Microsoft internet explorer
					$("#popupdealmap").css({
							"position": "absolute",
							//"background": "rgb(47,79,79)",
							"background-color": "blue",
							"top": 780,
							"left": 19,
							"opacity": 0.7,
							"-moz-opacity": 0.7,
							"-khtml-opacity": 0.7,
							"-webkit-opacity": 0.7,
							"-ms-filter": "\"progid:DXImageTransform.Microsoft.Alpha(opacity=70)\"",
							"filter": "progid:DXImageTransform.Microsoft.Alpha(opacity=70)"
			
					});
			 }
			 else if($.browser.safari)// jquery condition to test if the browser is Safari or Chrome (based on webkit)
			 {
				
					$("#popupdealmap").css({
						"position": "absolute",
						"background": "rgba(47,79,79,0.7)",
						"top": 808,
						"left": 18
						
					});
			 }
			 else if($.browser.mozilla) //jquery condition to test if the browser is Firefox
			 {
				
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 814,
							"left": 18
					});
			 }
			 else if($.browser.opera) //jquery condition to test if the browser is Opera
			 {
				
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 804,
							"left": 18
					});
			 }
			 else {
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 813,
							"left": 16
					});
			 };
	}else if (navigator.platform =="Win32") {//test if the operating system is Windows
	
			if($.browser.msie){	//jquery condition to test if the browser is Microsoft internet explorer

				$("#popupdealmap").css({
						"position": "absolute",
						"background": "rgb(47,79,79)",
						"text-align": "left",
						"top": 805,
						"left": 18,
						"opacity": 0.7,
						"-moz-opacity": 0.7,
						"-khtml-opacity": 0.7,
						"-webkit-opacity": 0.7,
						"-ms-filter": "\"progid:DXImageTransform.Microsoft.Alpha(opacity=70)\"",
						"filter": "progid:DXImageTransform.Microsoft.Alpha(opacity=70)"
		
				});
			 }
			 else if($.browser.safari)// jquery condition to test if the browser is Safari or Chrome (based on webkit)
			 {
				
					$("#popupdealmap").css({
						"position": "absolute",
						"background": "rgba(47,79,79,0.7)",
						"top": 828,
						"left": 18			
					});
			 }
			 else if($.browser.mozilla) //jquery condition to test if the browser is Firefox
			 {
				
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 821,
							"left": 19
					});
			 }
			 else if($.browser.opera) //jquery condition to test if the browser is Opera
			 {
				
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 807,
							"left": 18
					});
			 }
			 else {
					$("#popupdealmap").css({
							"position": "absolute",
							"background": "rgba(47,79,79,0.7)",
							"top": 813,
							"left": 16
						});
			};
	}else if(navigator.platform =="iPhone"){ //test if your Operating System is an iPhone
		
		if($.browser.safari){
			$("#popupdealmap").css({
						"position": "absolute",
						"background": "rgba(47,79,79,0.7)",
						"top": 823,
						"left": 18			
					});
		}else{
			$("#popupdealmap").css({
						"position": "absolute",
						"background": "rgba(47,79,79,0.7)",
						"top": 823,
						"left": 18			
					});
		}		
	};
	
	$(".view_deal_map_button").css({
		"opacity":1,
		"-ms-filter": "\"progid:DXImageTransform.Microsoft.Alpha(opacity=100)\"",
		"filter": "progid:DXImageTransform.Microsoft.Alpha(opacity=100)",
		"z-index":1000
	})
}

//disabling the deal map popup with jQuery magic!
function disablePopupsDealMap(){
	//disables popup only if it is enabled
		$("#map").css({
			"border-bottom-style": "solid"
		});
		$("#backgroundPopup").fadeOut("slow");
		$("#popupdealmap").fadeOut("slow");
	
}



// return the URL without '/emailme'

function linkto(){
	pathArray = window.location.pathname.split( '/' );
	newPathname = "";
	for ( i = 0; i < pathArray.length-2; i++ ) {
		newPathname += pathArray[i];
		newPathname += "/";
	}
	newURL = window.location.protocol + "//" + window.location.host + newPathname;
	return newURL;
}

// change the location for block element in paramter
function goslash(block){
	pathArray = window.location.pathname.split( '/' );
	newPathname = "";
	for ( i = 0; i < pathArray.length-block; i++ ) {
		newPathname += pathArray[i];
		newPathname += "/";
	}
	newURL = window.location.protocol + "//" + window.location.host + newPathname;
	return newURL;
}

function Print_Redeem_confirmation(){
		
	//disablePopups("#popupContact3");
	disablePopups("#popupContact2");
	//$("#backgroundPopup").fadeIn("slow");
	
	//centering with css
	centerPopups("#popupContact3");
	//load popup
	loadPopups("#popupContact3");
	
}
function Email_Redeem_confirmation(){
		
	//centering with css
	centerPopups("#popupContact3");
	//load popup
	loadPopups("#popupContact3");
	
}
function printRedeem(){
	
	//disablePopups("#popupContact3");
	disablePopups("#popupContact2");
	$("#backgroundPopup").fadeIn("slow");
	
	//centering with css
	centerPopups("#popupContact3");
	//load popup
	loadPopups("#popupContact3");
	
};
function checkEmail(inputvalue){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){  
	
		return true;
    }else{   
		
		return false;
    }
};


/* 
	//Update deal list in function categories and deals state:
	function updateDealList(cat,stat,metro){
			
			urlrquest="http://www.betheredeals.com/v2/index.php/deals/"+metro+"/displayListDealOnly";
			bodyContent = $.ajax({
				  url: urlrquest,
				  global: false,
				  type: "POST",
				  data: ({category: cat,state:stat}),
				  dataType: "html",
				  async:false,
				  success: function(msg){
					divDeals=document.getElementById('deal_list_content');
					divDeals.innerHTML=msg;
					$("#deal_list_content").slideDown();
				  }
			   }
			).responseText;	
	}	
*/

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	
	pathArray = window.location.pathname;
	if(pathArray.indexOf('home')==-1 && pathArray.indexOf('deals')!=-1){
		if(typeof(currentCategory2)=='undefined'){ 
			onLoadmap("all",'all');
		}else{
		onLoadmap("all",currentCategory2);
		}
		//alert(currentCategory2);
		//alert(pathArray.indexOf('home')+" 11& "+pathArray.indexOf('Home'));
	}

	
	
	
	// bind 'myForm' and provide a simple callback function 
    $('#loginpopupForm').ajaxForm(function() { 
    	var contentform = document.getElementById("warmingform");
    	var headerLogin = document.getElementById("login");
    	if(getCookie("user_email")=='' || getCookie("user_email")=='undefined'){
    		contentform.innerHTML = "Wrong login";
    	}else{	
    		disablePopups("#loginpopup");
    	}
    }); 
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){	
		centerPopups("#signupPopup");
		//load popup
		loadPopups("#signupPopup");
	});
	
	$(".link-3").click(function(){	
		centerPopups("#developerpopup");
		//load popup
		loadPopups("#developerpopup");
	});
	
	$("#large_photo").click(function(){
		//centering with css
		centerPopups("#dealPicture");
		//load popup
		loadPopups("#dealPicture");
		
	});
	$(".emailshare").click(function(){
		//centering with css
		centerPopups("#popupContact4");
		//load popup
		loadPopups("#popupContact4");
		
	});
	$(".logInButtom").click(function(){
		//centering with css
		centerPopups("#loginpopup");
		//load popup
		loadPopups("#loginpopup");
		
	});
	
	$("#websiteSahre").click(function(){
 
	  //centering with css
	  centerPopups("#websiteSahre");
	  //load popup
	  loadPopups("#websiteSahre");
	  
	 });
	
	$("#contact_popup").click(function(){
	  //centering with css
	  centerPopups("#contactus");
	  //load popup
	  loadPopups("#contactus");
	  
	 });
	 $("#T_2").click(function(){
 
	  //centering with css
	  centerPopups("#contactus");
	  //load popup
	  loadPopups("#contactus");
	  
	 });
	 
	
	$("#contactusClose").click(function(){
		 $("#contactus").slideUp();
		disablePopups("#contactus");
	});
	
	$("#developerpopupClose").click(function(){
		 $("#developerpopup").slideUp();
		disablePopups("#developerpopup");
	});
	$("#contact_submit").click(function(){
		document.getElementById("inputfields").style.display="none";
		document.getElementById('message-callback').innerHTML="<center><i style='color:#cccccc'>Loading...<i> <br/><br/><img src='/images/ajax-loader.gif' alt='Loading....' /> </center>";

	});
	
	/*---------------------------------------------*
	 |  Added 8/20/2011 - Dan Mayor
	 |  This simply clones the contact us
	 |  functionality gathering the field input
	 |  from the signup_60_popup form.
	 *---------------------------------------------*/
	$("#signup60_popup").click(function() {
		centerPopups("#signup60");
		loadPopups("#signup60");
	});
	
	$(".link-3").click(function() {
		//centerPopups("#developerpopup");
		//loadPopups("#developerpopup");
	});
	//$("#link-3").click(function(){
	//	$("#signup60").slideUp();
	//	disablePopups("#signup60");
	//});
	
	$("#signup60_submit").click(function(){
		document.getElementById("inputfields").style.display = "none";
		document.getElementById('message-callback-dev').innerHTML = "<center><i style='color:#cccccc'>Loading...<i> <br/><br/><img src='/images/ajax-loader.gif' alt='Loading....' /> </center>";
	});
	
	//Contact US Form management
	$('#myForm').ajaxForm(function() { 
		msgAnwser="<p class='contact_error_message'>";
		divmsg=document.getElementById('message-callback');
		res=0;
		if ( document.forms["myForm"].contact_name.value == "" ){
			msgAnwser+="Enter a valid name";
			document.getElementById('cname').style.color="red";
			res=1;
		}
		if (checkEmail(document.forms["myForm"].contact_email.value  )==false){
			msgAnwser+=", email address";
			document.getElementById('cemail').style.color="red";
			res=1;
		}
		
	if (document.forms["myForm"].contact_subject.value == "" ){
			msgAnwser+=", subject";
			document.getElementById('csubject').style.color="red";
			res=1;
		}
		if (document.forms["myForm"].contact_message.value == ""){
			msgAnwser+=", message";
			document.getElementById('cmessage').style.color="red";
			res=1;
		}
		msgAnwser+=", thank you! </p>";
		if(res==0){
			$.get("/application/libraries/contact_us.php", { name: document.forms["myForm"].contact_name.value, email: document.forms["myForm"].contact_email.value, subject: document.forms["myForm"].contact_subject.value, message: document.forms["myForm"].contact_message.value, company :document.forms["myForm"].contact_Company.value , city: document.forms["myForm"].contact_city.value }, function(data){
				
					divmsg.innerHTML="<b>Thank you! </b>";
					$("#contactus").slideUp();
					disablePopups("#contactus");
				
			});
		
		}else{
			divmsg.innerHTML=msgAnwser;			
			document.getElementById("inputfields").style.display="inline";
			
		}
	
	 }); 
			

	
	//----
	//developer API signup puForm management
	$('#signup_60_form').ajaxForm(function() { 
		msgAnwser="<p class='contact_error_message'> Enter a valid  ";
		divmsg=document.getElementById('message-callback-dev');
		res=0;
		if ( document.forms["signup_60_form"].cname.value == "" ){
			msgAnwser+=" company name";
			document.getElementById('_cname').style.color="red";
			res=1;
		}
		if (checkEmail(document.forms["signup_60_form"].email.value  )==false){
			msgAnwser+=" email";
			document.getElementById('_email').style.color="red";
			res=1;
		}
		
		if (document.forms["signup_60_form"].name.value == "" ){
			msgAnwser+=" name";
			document.getElementById('_name').style.color="red";
			res=1;
		}
		if (document.forms["signup_60_form"].phone.value == ""){
			msgAnwser+=" phone";
			document.getElementById('_phone').style.color="red";
			res=1;
		}
		if (document.forms["signup_60_form"].title.value == ""){
			msgAnwser+=" title";
			document.getElementById('_title').style.color="red";
			res=1;
		}
		if (document.forms["signup_60_form"].agree.checked != true){
			msgAnwser+="<br/ >Please accept terms";
			document.getElementById('_agree').style.color="red";
			res=1;
		}
		
		msgAnwser+=", thank you! </p>";
		if(res==0){
			document.getElementById("signup_60_form").style.display="none";
			document.getElementById('message-callback-dev').innerHTML="<center><i style='color:#cccccc'>Loading...<i> <br/><br/><img src='/images/ajax-loader.gif' alt='Loading....' /> </center>";
			$.get("/application/libraries/mobileappapply.php", { cname: document.forms["signup_60_form"].cname.value,name: document.forms["signup_60_form"].name.value, email: document.forms["signup_60_form"].email.value, title: document.forms["signup_60_form"].title.value, phone: document.forms["signup_60_form"].phone.value }, function(data){
				
					divmsg.innerHTML="<b>Thank you! </b>";
					$("#developerpopup").slideUp();
					disablePopups("#developerpopup");
				
			});
		
		}else{
			divmsg.innerHTML=msgAnwser;			
			document.getElementById("inputfields_dev").style.display="inline";
			
		}
	
	 });
	//-----
	$(".print_button").click(function(){
		
		document.getElementById("form_redeem_content").style.display="none";
		document.getElementById('message-callback_redeem').innerHTML="<center><i style='color:#cccccc'>Loading...<i> <br/><br/><img src='/images/ajax-loader.gif' alt='Loading....' /> </center>";
		
	})
	
	$(".mail_button").click(function(){
		document.getElementById("form_redeem_content").style.display="none";
		document.getElementById('message-callback_redeem').innerHTML="<center><i style='color:#cccccc'>Loading...<i> <br/><br/><img src='/images/ajax-loader.gif' alt='Loading....' /> </center>";
		
	})
	//Share Via Email Form Managmement:
	
	
	//Redemption Form management By using the printing option:
	
	$('#redemptionFormByPrint').ajaxForm(function() { 
		
		msgAnwser="<p class='contact_error_message'> Enter a valid ";
		divmsg=document.getElementById('message-callback_redeem');
		res=0;
		if (document.forms["redemptionFormByEmail"].typeDeal.value=="GLNdeal"){
			if ( document.forms["redemptionFormByEmail"].first_name.value == "" ){
				msgAnwser+="first name";
				document.getElementById('fname').style.color="red";
				res=1;
			}
			if (document.forms["redemptionFormByEmail"].last_name.value ==""){
				msgAnwser+=", last name";
				document.getElementById('lname').style.color="red";
				res=1;
			}
			
			if (checkEmail(document.forms["redemptionFormByEmail"].email_redeem.value) == false ){
				msgAnwser+=", email address";
				document.getElementById('cemail').style.color="red";
				res=1;
			}
		}
		
		msgAnwser+=", thank you! </p>";
		
		
		
		if(res==0){
			
				$.post("http://www.betheredeals.com/popupcontroller", { 
					   metro_id: document.forms["redemptionFormByEmail"].metroarea_id.value,
					   typeDeal: document.forms["redemptionFormByEmail"].typeDeal.value,
					   first_name: document.forms["redemptionFormByEmail"].first_name.value,
					   last_name: document.forms["redemptionFormByEmail"].last_name.value,
					   deal_id:document.forms["redemptionFormByEmail"].deal_id.value,
					   redemption_id:document.forms["redemptionFormByEmail"].redemption_id.value,
					   email_user: document.forms["redemptionFormByEmail"].email_redeem.value },
			   function(data){
					//alert("Data Loaded: " + data);
						
					window.open('http://www.betheredeals.com/deal/'+document.forms["redemptionFormByEmail"].metro_name.value+"/printdeal/"+document.forms["redemptionFormByEmail"].deal_id.value,'Win1', 'width=430,height=630');
					var congrat=$('#popupContact3').html();
					$('#popupContact2').html(congrat);
					//document.getElementById("get_deal_btn").style.display="none";
					
				
				});
	
		}else{
			divmsg.innerHTML=msgAnwser;
			document.getElementById("form_redeem_content").style.display="inline";
		}
			
	});
		
	//Redemption Form management By using the mail option:
	$('#redemptionFormByEmail').ajaxForm(function() { 
	
		msgAnwser="<p class='contact_error_message'>";
		divmsg=document.getElementById('message-callback_redeem');
		res=0;
		
		if (document.forms["redemptionFormByEmail"].typeDeal.value=="GLNdeal"){
			if ( document.forms["redemptionFormByEmail"].first_name.value == ""  ){
				msgAnwser+="Enter a valid first name";
				document.getElementById('fname').style.color="red";
				res=1;
			}
			if (document.forms["redemptionFormByEmail"].last_name.value ==""){
				msgAnwser+=", last name";
				document.getElementById('lname').style.color="red";
				res=1;
			}
		}
		if (checkEmail(document.forms["redemptionFormByEmail"].email_redeem.value) == false ){
			msgAnwser+=", email address";
			document.getElementById('cemail').style.color="red";
			res=1;
		}
	
		
		msgAnwser+=", thank you! </p>";
		
		
		if(res==0){
			
				$.post("http://www.betheredeals.com/popupcontroller", { 
					   redemptionWay: "byEmail",
					   metro_name: document.forms["redemptionFormByEmail"].metro_name.value,
					   metro_id: document.forms["redemptionFormByEmail"].metroarea_id.value,
					   typeDeal: document.forms["redemptionFormByEmail"].typeDeal.value,
					   first_name: document.forms["redemptionFormByEmail"].first_name.value,
					   last_name: document.forms["redemptionFormByEmail"].last_name.value,
					   deal_id:document.forms["redemptionFormByEmail"].deal_id.value,
					   redemption_id:document.forms["redemptionFormByEmail"].redemption_id.value,
					   email_user: document.forms["redemptionFormByEmail"].email_redeem.value, 
					   title: document.forms["redemptionFormByEmail"].title.value,
					   short_desc: document.forms["redemptionFormByEmail"].short_desc.value,
					   venue_name: document.forms["redemptionFormByEmail"].venue_name.value,
					   start_time: document.forms["redemptionFormByEmail"].start.value,
					   end_time: document.forms["redemptionFormByEmail"].end.value,
					   long_desc: document.forms["redemptionFormByEmail"].long_desc.value,
					   address: document.forms["redemptionFormByEmail"].address.value,
					   red_desc: document.forms["redemptionFormByEmail"].red_desc.value},
			   function(data){ 
					//alert("Data Loaded: " + data);
						var congrat=$('#popupContact3').html();
						$('#popupContact2').html(congrat);
					//window.open('http://www.betheredeals.com/v2/deal/'+document.forms["redemptionFormByEmail"].metro_name.value+"/printdeal/"+document.forms["redemptionFormByEmail"].deal_id.value,'Win1', 'width=430,height=630');
					//document.getElementById("get_deal_btn").style.display="none";
				//$('#popupContact2').slideUp();disablePopups('#popupContact2');
				//alert(data);
					//$('#popupContact2').slideUp();disablePopups('#popupContact2');;
				
				});
		
		}else{
			divmsg.innerHTML=msgAnwser;
			document.getElementById("form_redeem_content").style.display="inline";
		}
			
	});
		
	
		
	//Get deal Button event
	$("#get_deal_btn").click(function(){
		
		
		//centering with css
		centerPopups("#popupContact2");
		//load popup
		loadPopups("#popupContact2");
	});

		
	
	$(".Email_redeem").click(function(){
		disablePopups("#popupContact2");
		
		//centering with css
		centerPopups("#popupContact3");
		//load popup
		loadPopups("#popupContact3");
	});
	
	
	$("#buttonNext").click(function(){
	
		disablePopup();
		//centering with css
		centerPopup2();
		//load popup
		loadPopup2();
	});
	
	//CLOSING POPUP
	
	
	//Click the x event!
	$("#loginpopupClose").click(function(){
		disablePopups("#loginpopup");
		disablePopups("#dealPicture");
		
	});
	
	$("#dealpictureClose").click(function(){
		disablePopups("#dealPicture");
	});
	//Click the x event!
	$("#signupPopupClose").click(function(){
		disablePopups("#signupPopup");
	});
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose2").click(function(){
		disablePopups("#popupContact2");
	
	});
	var RedemptionPopupContent="";
	if (document.getElementById("popupContact2")!="undefined" || document.getElementById("popupContact2")!= null){
		RedemptionPopupContent=$('#popupContact2').html();
	}
	
	$("#RedemptionClose").click(function(){
		//$('#popupContact2').html(RedemptionPopupContent);
		document.getElementById("popupContact3_content").style.display="none";
		document.getElementById("form_redeem_content").style.display="block";
		alert('ok');
		disablePopups("#popupContact2");
		
		
	
	});
	
	
	
	$("#popupContactClose2_bigger").click(function(){
		disablePopups("#popupContact2_bigger");
		
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		
		
	});

	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose3").click(function(){
		disablePopups("#popupContact3");
	});
	

	
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose4").click(function(){
		disablePopups("#popupContact4");
		
		
	});

	/*
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus4==1){
			disablePopup4();
			location.href=linkto();
		}
	});
	*/
	//CLOSING POPUP
	//Click the x event!
	$("#popupdealmapClose").click(function(){
		disablePopupsDealMap();
	});
	//Click out event!
	$("#popupdealmapClose").click(function(){
		disablePopupsDealMap();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus4==1){
			disablePopupsDealMap();
			disablePopups("#dealPicture");
		}
	});
	
	//Home page: List diplay and Map display mangagment.
	//document.getElementById('deal_map').innerHTML="";
	//document.getElementById('deal_map').innerHTML="<center><div id='map' style='width: 460px; height: 460px;'></div></center>";
			$(".display_list").css({
				"color":"#cccccc"
			});
			$(".display_map").css({
				"color":"#747474"
			});
			
			
		  	$("#deal_list").hide("slow");
		    $("#deal_map").show("slow", function() {
			// Animation complete.
			onLoadmap("all","all");
			});
		  
	//when click on display map
	 $(".display_map").click(function () {
	// document.getElementById('deal_map').innerHTML="<br/><br/><center><div id='map' style='width: 460px; height: 460px;'></div></center>";
			$(".display_list").css({
				"color":"#cccccc"
			});
			$(".display_map").css({
				"color":"#747474"
			});
			
			
		  	$("#deal_list").hide("slow");
		    $("#deal_map").show("slow", function() {
			// Animation complete.
			onLoadmap("all","all");
			});
		  
	});
	
	
	// when click on the list display
	  $(".display_list").click(function () {
		  disablePopupsDealMap();
		  $(".display_list").css({
				"color":"#747474"
			});
			$(".display_map").css({
				"color": "#cccccc"
			});
		  
		  $("#deal_map").hide("slow");
		  $("#deal_list").show("slow");
	 });
	 
	  
	// when the user clicks on the contact link on the left side 
	 $("#Tab_2").click(function () {
		  //centering with css
	  centerPopups("#contactus");
	  //load popup
	  loadPopups("#contactus");
	 });
	
		
	
});



