// JavaScript Document

var doc_root="https://www.drinkmercy.com";
var doc_root_http="http://www.drinkmercy.com";

function isiPad(){
    return (navigator.platform.indexOf("iPad") != -1);
}



jQuery(document).ready(function(){
	
	
	 
	
	//check if browser is IE6
	if(jQuery.browser.msie && jQuery.browser.version=="6.0") {
		jQuery("div[id*=parallax").hide();	
		
		/*jQuery("#confirm-button").css("padding","20px");*/
		jQuery("#confirm-button").css("position","relative");
		jQuery("#confirm-button").css("bottom","20px");
		jQuery("#confirm-button").css("display","block");
		
		
		//turning off clouds for big screen
		jQuery(".leftTopClouds").hide();
		jQuery(".rightTopClouds").hide();
		jQuery(".leftBottomClouds").hide();
		jQuery(".rightBottomClouds").hide();
		
		
		//turning off corner links
		jQuery("#topLeftLink").hide();
		jQuery("#topRightLink").hide();
		jQuery("#BottomLeftLink").hide();
		jQuery("#BottomRightLink").hide();
		
		//turning off corner link frames
		jQuery("#topLeftLinkFrame").hide();
		jQuery("#topRightLinkFrame").hide();
		jQuery("#BottomLeftLinkFrame").hide();
		jQuery("#BottomRightLinkFrame").hide();
		
		//turning bottom corner links 2. version
		jQuery("#BottomLeftLink2").hide();
		jQuery("#BottomRightLink2").hide();
		
		//turning off corner links frames 2. version
		jQuery("#BottomLeftLinkFrame2").hide();
		jQuery("#BottomRightLinkFrame2").hide();
		
		jQuery("#twitter").hide();
		jQuery("#twitterFrame").hide();
		jQuery("#facebook").hide();
		jQuery("#facebookFrame").hide();
	}
	else {
	//top clouds are inserted into "include-top-clouds-1.php for faster loading
	jQuery('#parallax').jparallax({mouseport:jQuery('body'), xparallax:true, yparallax:false});
	jQuery('#parallax2').jparallax({mouseport:jQuery('body'), xparallax:true, yparallax:false});
	jQuery('#parallax3').jparallax({mouseport:jQuery('body'), xparallax:true, yparallax:false});	
	jQuery('#parallax4').jparallax({mouseport:jQuery('body'), xparallax:true, yparallax:false});	
	

	
	//jQuery('#parallax').jparallax({mouseport:jQuery('body')}, {xtravel: '60px', ytravel:'40px'},{xtravel: '80px',ytravel:'30px'},{xtravel: '100px',ytravel:'20px'});
//	jQuery('#parallax2').jparallax({mouseport:jQuery('body')}, {xtravel: '60px', ytravel:'40px'},{xtravel: '80px',ytravel:'30px'},{xtravel: '100px',ytravel:'20px'});	
//	jQuery('#parallax3').jparallax({mouseport:jQuery('body')}, {xtravel: '60px', ytravel:'40px'},{xtravel: '80px',ytravel:'30px'},{xtravel: '100px',ytravel:'20px'});	
//	jQuery('#parallax4').jparallax({mouseport:jQuery('body')}, {xtravel: '60px', ytravel:'40px'},{xtravel: '80px',ytravel:'30px'},{xtravel: '100px',ytravel:'20px'});			
//	
	

	}
	
	
	//switching between big and small screens
	if((jQuery(window).width()<=800) || isiPad()){
		
		//turning off clouds for big screen
		jQuery(".leftTopClouds").hide();
		jQuery(".rightTopClouds").hide();
		jQuery(".leftBottomClouds").hide();
		jQuery(".rightBottomClouds").hide();
		
		
		//turning off corner links
		jQuery("#topLeftLink").hide();
		jQuery("#topRightLink").hide();
		jQuery("#BottomLeftLink").hide();
		jQuery("#BottomRightLink").hide();
		
		//turning off corner link frames
		jQuery("#topLeftLinkFrame").hide();
		jQuery("#topRightLinkFrame").hide();
		jQuery("#BottomLeftLinkFrame").hide();
		jQuery("#BottomRightLinkFrame").hide();
		
		//turning bottom corner links 2. version
		jQuery("#BottomLeftLink2").hide();
		jQuery("#BottomRightLink2").hide();
		
		//turning off corner links frames 2. version
		jQuery("#BottomLeftLinkFrame2").hide();
		jQuery("#BottomRightLinkFrame2").hide();
		
		
		//turning ON 4 bottom links
		jQuery("#small_screen_menu").show();
		jQuery("#small_screen_menu a").mouseover(function(){
			jQuery(this).animate({'bottom':'20px'},'fast','swing');
		});
		jQuery("#small_screen_menu a").mouseout(function(){
			jQuery(this).animate({'bottom':'0px'},'fast','swing');
		});
		
		
		jQuery("#twitter").css("right", "0px");
		jQuery("#twitterFrame").css("right", "0px");
		jQuery("#facebook").css("right", "0px");
		jQuery("#facebookFrame").css("right", "0px");
		
	}
	else {
		jQuery(".leftTopCloudsSmall").hide();
		jQuery(".rightTopCloudsSmall").hide();
		jQuery(".leftBottomCloudsSmall").hide();
		jQuery(".rightBottomCloudsSmall").hide();
	}

	/* ******** TOP LEFT LINK ********** */
	jQuery("#topLeftLinkFrame").hover(function(){
		//alert("Cao");
		jQuery("#topLeftLink").stop().animate({'top':'150px'},'fast','swing');
		jQuery("#topLeftLinkFrame").css("height","142px");
		
	 },
	function(){
		jQuery("#topLeftLink").stop().animate({'top':'110px'},'fast','swing');
		jQuery("#topLeftLinkFrame").css("height","112px");
	});
	
	jQuery("#topLeftLinkFrame").click(function(){
		window.location=doc_root+'/videos/';
	});
	
	/* ************************************ */
	
	/* ******** TOP RIGHT LINK ********** */
	jQuery("#topRightLinkFrame").mouseover(function(){
		jQuery("#topRightLink").stop().animate({'top':'140px'},'fast','swing');
		jQuery("#topRightLinkFrame").css("height","197px");
	 });
	jQuery("#topRightLinkFrame").mouseout(function(){
		jQuery("#topRightLink").stop().animate({'top':'90px'},'fast','swing');
		jQuery("#topRightLinkFrame").css("height","147px");
	});
	
	jQuery("#topRightLinkFrame").click(function(){
		window.location=doc_root+'/shop/';
	});
	
	/* ************************************ */
	
	/* ******** BOTTOM LEFT LINK ********** */
	jQuery("#BottomLeftLinkFrame").mouseover(function(){
		jQuery("#BottomLeftLink").stop().animate({'bottom':'140px'},'fast','swing');
		jQuery("#BottomLeftLinkFrame").css("height","148px");
	 });
	jQuery("#BottomLeftLinkFrame").mouseout(function(){
		jQuery("#BottomLeftLink").stop().animate({'bottom':'120px'},'fast','swing');
		jQuery("#BottomLeftLinkFrame").css("height","128px");
	});
	
	jQuery("#BottomLeftLinkFrame").click(function(){
		window.location=doc_root+'/news';
	});
	
	/* ************************************ */
	
	/* ******** BOTTOM RIGHT LINK ********** */
	jQuery("#BottomRightLinkFrame").mouseover(function(){
		//alert("Cao");
		jQuery("#BottomRightLink").stop().animate({'bottom':'150px'},'fast','swing');
		jQuery("#BottomRightLinkFrame").css("height","201px");
	 });
	jQuery("#BottomRightLinkFrame").mouseout(function(){
		jQuery("#BottomRightLink").stop().animate({'bottom':'120px'},'fast','swing');
		jQuery("#BottomRightLinkFrame").css("height","171px");
	});
	
	
	//Testimonials popup code
	/*jQuery("#BottomRightLinkFrame").click(function(){
		//kada se klikne na desni link
			if(window.location.protocol=='https:'){
					script_url=doc_root+"/checkcookie-testimonials.php";	
				}
				else {
					script_url=doc_root_http+"/checkcookie-testimonials.php";	
				}	
		
			jQuery.post(script_url,
					function(data) {
					 if(data=='yes'){
								jQuery("#testimonials_popup_wrapper").hide();
								window.location=doc_root+'/testimonials/'
					 }
					 else {
						 
						 	//setting the popup in the middle of the screen
							//depending on browser window width
							bwidth=jQuery(window).width();
							popup_offset_left=(bwidth-519)/2;
							jQuery("#testimonials_popup_wrapper").css("left",popup_offset_left);	
						 
						 	if(jQuery.browser.msie){
								//jQuery('html, body').animate({scrollTop:0}, 'slow');
								jQuery("#testimonials_popup_wrapper").slideDown(600);
							}
							else {
								//jQuery('html, body').animate({scrollTop:0}, 'slow');
								jQuery("#testimonials_popup_wrapper").show('bounce',600);
							}
					 }
					});
		
	});*/
	
	jQuery("#BottomRightLinkFrame").click(function(){
		window.location=doc_root+'/testimonials/';
	});
	
	/* ************************************ */
	
	
	/* ================ DRUGA VERZIJA BOTTOM LINKOVA ========================= */
	
	/* ******** BOTTOM LEFT LINK 2 ********** */
	jQuery("#BottomLeftLinkFrame2").mouseover(function(){
		//alert("Cao");
		jQuery("#BottomLeftLink2").stop().animate({'bottom':'140px'},'fast','swing');
		jQuery("#BottomLeftLinkFrame2").css("height","148px");
	 });
	jQuery("#BottomLeftLinkFrame2").mouseout(function(){
		jQuery("#BottomLeftLink2").stop().animate({'bottom':'120px'},'fast','swing');
		jQuery("#BottomLeftLinkFrame2").css("height","128px");
	});
	
	jQuery("#BottomLeftLinkFrame2").click(function(){
		//window.location=doc_root+'/news/?cat=6';
		window.location=doc_root+'/news';
	});
	
	/* ************************************ */
	
	/* ******** BOTTOM RIGHT LINK  2 ********** */
	jQuery("#BottomRightLinkFrame2").mouseover(function(){
		//alert("Cao");
		jQuery("#BottomRightLink2").stop().animate({'bottom':'150px'},'fast','swing');
		jQuery("#BottomRightLinkFrame2").css("height","201px");
	 });
	jQuery("#BottomRightLinkFrame2").mouseout(function(){
		jQuery("#BottomRightLink2").stop().animate({'bottom':'120px'},'fast','swing');
		jQuery("#BottomRightLinkFrame2").css("height","171px");
	});
	
	//Testimonials popup code
	/*jQuery("#BottomRightLinkFrame2").click(function(){
		//kada se klikne na desni link
			jQuery.post(doc_root+"/checkcookie-testimonials.php",
					function(data) {
					 if(data=='yes'){
								jQuery("#testimonials_popup_wrapper").hide();
								window.location=doc_root+'/testimonials/'
					 }
					 else {
						 
						 	//setting the popup in the middle of the screen
							//depending on browser window width
							bwidth=jQuery(window).width();
							popup_offset_left=(bwidth-519)/2;
							jQuery("#testimonials_popup_wrapper").css("left",popup_offset_left);	
						 
						 	if(jQuery.browser.msie){
								//jQuery('html, body').animate({scrollTop:0}, 'slow');
								jQuery("#testimonials_popup_wrapper").slideDown(600);
							}
							else {
								//jQuery('html, body').animate({scrollTop:0}, 'slow');
								jQuery("#testimonials_popup_wrapper").show('bounce',600);
							}
					 }
					});
		
	});*/
	
	jQuery("#BottomRightLinkFrame2").click(function(){
		window.location=doc_root+'/testimonials/';
	});
	
	/* ************************************ */
	
	/* ******** AUDIO PLAYER ********** */
	
	//music = document.getElementById("player");
//	
//	jQuery("#headermenu a").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#headermenu a").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	jQuery("#footermenu a").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#footermenu a").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#topLeftLinkFrame").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#topLeftLinkFrame").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#topRightLinkFrame").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#topRightLinkFrame").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#BottomLeftLinkFrame").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#BottomLeftLinkFrame").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#BottomRightLinkFrame").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#BottomRightLinkFrame").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	//druga verzija linkova
//	
//	jQuery("#BottomLeftLinkFrame2").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#BottomLeftLinkFrame2").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#BottomRightLinkFrame2").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#BottomRightLinkFrame2").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
//	
//	jQuery("#small_screen_menu a").mouseover(function(e){
//		music.play();
//	});
//	jQuery("#small_screen_menu a").mouseleave(function(e){
//		music.pause();
//		music.currentTime=0;
//	});
//	
	
	
	
	
	
	/* ******** TWITTER AND FACEBOOK LINK ********** */
	jQuery("#twitterFrame").mouseover(function(){
		//alert("Cao");
		jQuery(this).stop().animate({'bottom':'390px'},'fast','swing');
		jQuery("#twitter").stop().animate({'bottom':'390px'},'fast','swing');
		jQuery("#twitter").css('backround','images/twitter.png');
		jQuery("#twitter").css('background-position','bottom');
		jQuery("#twitter").css('height','115px');
		jQuery("#twitterFrame").css('height','115px');
		
		
	 });
	jQuery("#twitterFrame").mouseout(function(){
		jQuery(this).stop().animate({'bottom':'380px'},'fast','swing');
		jQuery("#twitter").stop().animate({'bottom':'380px'},'fast','swing');
		jQuery("#twitter").css('backround','images/twitter.png');
		jQuery("#twitter").css('background-position','top');
		jQuery("#twitter").css('height','82px');
		jQuery("#twitterFrame").css('height','82px');
	});
	/*
	jQuery("#twitterFrame").click(function(){
		xwindow.location='http://twitter.com/drinkmercy';	
	});
	*/
	jQuery("#facebookFrame").mouseover(function(){
		//alert("Cao");
		jQuery(this).stop().animate({'bottom':'320px'},'fast','swing');
		jQuery("#facebook").stop().animate({'bottom':'320px'},'fast','swing');
		jQuery("#facebook").css('backround','images/facebook.png');
		jQuery("#facebook").css('background-position','bottom');
		jQuery("#facebook").css('height','115px');
		jQuery("#facebookFrame").css('height','115px');
		
	 });
	jQuery("#facebookFrame").mouseout(function(){
		jQuery(this).stop().animate({'bottom':'310px'},'fast','swing');
		jQuery("#facebook").stop().animate({'bottom':'310px'},'fast','swing');
		jQuery("#facebook").css('backround','images/facebook.png');
		jQuery("#facebook").css('background-position','top');
		jQuery("#facebook").css('height','85px');
		jQuery("#facebookFrame").css('height','85px');
		
	});
	/*
	jQuery("#facebookFrame").click(function(){
		window.location='http://www.facebook.com/drinkmercy';	
	});
	*/
	/* ********* POPUP *********** */
	
	//checkCookie();
	
	/* ************************************ */
	
	/* **** TURNING ON SIDEMENU ********** */
	
	//jQueryscreen_height=jQuery(window).height();
//	jQueryscreen_width=jQuery(window).width();
//	
//	if(jQueryscreen_width<=950){
//		//alert(jQueryscreen_width);
//		jQuery("#sidemenu").fadeIn(400);
//	}
//	else {
//		//alert(jQueryscreen_width);
//		jQuery("#sidemenu").hide();
//	}
	
	/* ************************************ */
	
	//ukljucivanje popup-a za IE uvek
	if(jQuery.browser.msie){
	//privremeno iskljuceno
	//Show();  
    }
  
  	//newsletter link in footer triggers popup
	jQuery("a#newsletter").click(function(){
		//privremeno iskljuceno
		//Show();
	});
	
	
	
	
	/* ****** NEWSLETTER ********** */
	jQuery("#mercynewsletterform input.sendbutton").click(function(){
			subscribe();
	});
	
	
	jQuery("a#newsletter").click(function(e){
		e.preventDefault();

	if(jQuery("#newsletterbox").css('display')=='none'){
	
		//setting the popup in the middle of the screen
		//depending on browser window width
		bwidth=jQuery(window).width();
		popup_offset_left=(bwidth-340)/2;
		jQuery("#newsletterbox").css("left",popup_offset_left);
		
		
		//turning video off on video page	
		jQuery("#video-frame").hide();	
		//turning off news-featured-posts content slider on testimonials page
		jQuery("#news-featured-posts").hide();
		
		//jQuery('html, body').animate({scrollTop:0}, 'slow');
		jQuery("#newsletterbox").show('bounce',400);
		
		
		
	}
	else {
		//jQuery("#newsletterbox").css('display','none');
	}
	});
	
	
	//brisanje teksta iz newsletter inputa
	jQuery("#csmail").click(function(){
		jQuery("#csmail").val('');
		jQuery("#csmail").focus();
	});
	
	jQuery("#cancel_newsletter").click(function(){
		if(jQuery.browser.msie){
		jQuery("#newsletterbox").hide('fade',400);
		//turning video ON on video page	
		jQuery("#video-frame").show();	
		//turning ON news-featured-posts content slider on testimonials page
		jQuery("#news-featured-posts").show();
		}
		else
		{
		jQuery("#newsletterbox").hide('fade',400);
		//turning video ON on video page	
		jQuery("#video-frame").show();
		//turning ON news-featured-posts content slider on testimonials page
		jQuery("#news-featured-posts").show();
		}
		
	});
	
	
	//checkout page, ispisivanje poruke o gresci
	function validateEmailAddress(email){
				
				jQuery.post(doc_root_http+"/wp-content/themes/mercytheme/validateemail.php",
				{emailaddress:email }, 
                   function(data) {
					
					 if(data=='valid'){
						 
					 }
					 else
					 {
						jQuery("#email").addClass('error');
						jQuery("#email").val('Email address does not exist'); 
					 }
					});

				
				 return false; 
				}
	
	//global timeout_id 
	var timeout_id;
	
	function checkForError(){
		
		reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		address = jQuery("#email").val();
		
		if(reg.test(address) == false) {
			jQuery("#email").addClass('error');
			jQuery("#email").val('Invalid email address');
		}
		else {
			jQuery("#email").removeClass('error');
			validateEmailAddress(address);
		}
		
		
		timeout_id=setTimeout(GoToConfirmPage,1000);
	}
	
	function GoToConfirmPage(){
		number=jQuery(".error").length;
		//alert("NUMBER OF ERRORS:"+number);
		if(number>0){
		jQuery(".form_error").show(400);
		}
		else {
		jQuery(".form_error").hide(400);
		document.forms[1].submit();		
		}
		clearTimeout(timeout_id);
	}
	
	jQuery("#checkout-button").click(function(){
		
		if(jQuery("#same-shipping").attr('checked')){
		jQuery("#step3wrapper").hide('fade',400);	
		
		jQuery("#shipping-address").val(jQuery("#billing-address").val())
		jQuery("#shipping-city").val(jQuery("#billing-city").val());
		jQuery("#shipping-country").val(jQuery("#billing-country").val());
		
		//jQuery("#shipping-country").change();
		
		jQuery("#shipping-state-menu").val(jQuery("#billing-state-menu").val());
		jQuery("#shipping-state").val(jQuery("#billing-state").val());
		jQuery("#shipping-postcode").val(jQuery("#billing-postcode").val());
		}
		
		checkForError();
		//timeout_id=setTimeout(checkForError,500);
	});
	
	
	
	
	
	/* ****** SHIPPING ADDRESS REMOVAL ********** */
	jQuery("#same-shipping").attr('checked',true);
	jQuery("#step3wrapper").hide();	
	jQuery("#same-shipping").click(function(){
		if(jQuery("#same-shipping").attr('checked')){
		jQuery("#step3wrapper").hide('fade',400);	
		
		jQuery("#shipping-address").val(jQuery("#billing-address").val())
		jQuery("#shipping-city").val(jQuery("#billing-city").val());
		jQuery("#shipping-country").val(jQuery("#billing-country").val());
		jQuery("#shipping-country").change();
		jQuery("#shipping-state-menu").val(jQuery("#billing-state-menu").val());
		jQuery("#shipping-state").val(jQuery("#billing-state").val());
		jQuery("#shipping-postcode").val(jQuery("#billing-postcode").val());
		}
		else {
		jQuery("#step3wrapper").show('fade',400);	
		
		jQuery("#shipping-address").val('');
		jQuery("#shipping-city").val('');
		jQuery("#shipping-country").val('US');
		jQuery("#shipping-state-menu").val('');
		jQuery("#shipping-state").val('');
		jQuery("#shipping-postcode").val('');
		}
		
	});
	
	/* *********** AUTOMATSKO POPUNJAVANJE SHIPPING POLJA ************* */
	
	
		
			jQuery("#billing-address").change(function(){
				if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-address").val();
				jQuery("#shipping-address").val($value);
				}
			});
			
			jQuery("#billing-city").change(function(){
				if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-city").val();
				jQuery("#shipping-city").val($value);
				}
			});
			
			jQuery("#billing-country").change(function(){
				if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-country").val();
				jQuery("#shipping-country").val($value);
				
				jQuery("#shipping-country").change();
				}
			});
			
			
			jQuery("#billing-state-menu").change(function(){
				if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-state-menu").val();
				jQuery("#shipping-state-menu").val($value);
				}
			});
			
			
			jQuery("#billing-state").change(function(){
				//if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-state").val();
				jQuery("#shipping-state").val($value);
				//}
			});
			
			jQuery("#billing-postcode").change(function(){
				if(jQuery("#same-shipping").attr('checked')){
				$value=jQuery("#billing-postcode").val();
				jQuery("#shipping-postcode").val($value);
				}
			});
	
	
	
			// ================= TESTIMONIALS =================================
			
			jQuery("#testimonials_popup_wrapper a.submit_your_own").click(function(e){
						e.preventDefault();
						if(window.location.protocol=='https:'){
							page_redirect_url=doc_root+'/testimonials';
						}
						else {
							page_redirect_url=doc_root_http+'/testimonials';
						}	
						window.location=page_redirect_url;
			});
		
		
			jQuery("#testimonials_popup_wrapper a.close_testimonials_popup").click(function(e){
				e.preventDefault();
				if(jQuery.browser.msie){
						jQuery("#testimonials_popup_wrapper").hide('fade',400,function(){
						jQuery("#testimonials-post-list").show('fade',400);
						jQuery("#main").css("min-height","0px");
						});
				}
				else {
						jQuery("#testimonials_popup_wrapper").hide('fade',400,function(){
						jQuery("#testimonials-post-list").show('fade',400);
						jQuery("#main").css("min-height","0px");
						});
				}
			});
			
	
			
  
});


function destroySession(){
			
			dataString='';
			jQuery.ajax({  
			   type: "GET",  
			   datatype:"text",
			   url: doc_root+"/destroysession.php",  
			   data: dataString,  
			   success: function(data) {  
				 jQuery(".form_error").show(400);
				 window.location=doc_root;
			   },
			   error: function(xhr) {
					/*alert('Error: ' + xhr.status + ' ' + xhr.statusText);*/
				}
			 });  
			 return false; 
			}
			
function destroySession2(url){
			
			dataString='';
			jQuery.ajax({  
			   type: "GET",  
			   datatype:"text",
			   url: doc_root+"/destroysession.php",  
			   data: dataString,  
			   success: function(data) {  
			   window.location=url; 
			   },
			   error: function(xhr) {
					
				}
			 });  
			 return false; 
			}

function destroySession3(url){
jQuery.post(doc_root+"/destroysession.php",
                   function(data) {
					 
					 if(data=='OK'){
						window.location=url; 
					 }
					});
return false;					
}



function setCompatibilityCookie(c_name, value, expiredays) {
var exdate = new Date();
exdate.setTime(exdate.getTime() + (expiredays * 86400000));
document.cookie= c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + exdate.toUTCString());}


function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+jQuery/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function checkCookie()
{
var first=getCookie("first");
  if (first!=null && first!="")
  {
  //alert(first);
  
  }
else
  {
  first="yes";
  if (first!=null && first!="")
    {
	Show();
    setCookie("first",first,365);
    }
  }
}

function Show(){
	jQuerymyheight=jQuery(window).height();
	jQuerymywidth=jQuery(window).width();
	jQuerymywidth=(jQuerymywidth-460)/2;
	jQuerymyheight=(jQuerymyheight-300)/2;
	
	jQuery("#light").css("left",jQuerymywidth);
    jQuery("#light").show('bounce',400);
	jQuery("#fade").fadeIn(400);
		
  }

function Hide(){
    jQuery("#light").hide('explode',400);
	jQuery("#fade").fadeOut(400);
  }
  





