$(document).ready(function() {
		$('#middleStuff').css('margin-top', '85px').children('.btnOutline:lt(2)').hide();
		$('#middleStuff').children('.btnOutline:eq(2)').css('margin-top', '16px');
		$('#footerBlock').hide().css('margin-top', '-100px').fadeIn('fast');
		
//		$('#g1').css('margin-left', '-125px').css('position', 'absolute');//login google ads
		$('#g2').css('margin-left', '1120px').css('position', 'absolute');		
		$('#g1').css('margin-left', '-125px').css('position', 'absolute');//login google ads
		//$('#g2').css('margin-left', '2120px').css('position', 'absolute');
	
$('#gAdsMain').fadeIn('fast');
								
	//checks flash player version
	var playerVersion = swfobject.getFlashPlayerVersion();
	var flashVersion = playerVersion.major;
	if(flashVersion<=8){
		window.open("http://www.yogoguide.com/universal/sansflash/sansflash.php", "_self");
	}
		
	if(/MSIE (6)/.test(navigator.userAgent) && navigator.platform == "Win32"){
		$('#g1').css('margin-left', '870px').css('position', 'absolute');//login google ads
		$('#g2').css('margin-left', '2120px').css('position', 'absolute');

		ie='ie6';
   }else if(/MSIE (7)/.test(navigator.userAgent) && navigator.platform == "Win32"){   
   		$('#g1').css('margin-left', '870px').css('position', 'absolute');//login google ads
		$('#g2').css('margin-left', '2120px').css('position', 'absolute');

	 	ie='ie7';
   }else if(/MSIE (8)/.test(navigator.userAgent) && navigator.platform == "Win32"){   
	 	ie='ie8';
   }	
// if (ie!='ie6' || ie!='ie7' || ie!='ie8'){			   					   
   /* IE only -- for rounded div corners */
//   DD_roundies.addRule('#Col1 .btnOutline', '5px', false);
//   DD_roundies.addRule('#Col2 .btnOutline', '5px', false);
//   DD_roundies.addRule('#Col3 .btnOutline', '5px', false);
//   DD_roundies.addRule('#Col4 .btnOutline', '5px', false);
//   DD_roundies.addRule('.div3', '5px', false);
//   DD_roundies.addRule('#parisBtn', '5px', false);
//   DD_roundies.addRule('#newyorkBtn', '5px', false);
//   DD_roundies.addRule('#container', '10px', false);
//   DD_roundies.addRule('#containerDiv', '10px', false);
// }
	//adding click function to login button
 	var loginBtn = document.getElementById('.btnOutline:first');
 	$(loginBtn).click(function(){loginAppear();});

menuRollOvers();
menuDelegate();

$("#parisBtn").click(function() {window.open('http://www.yogoguide.com/paris.html', '_self' ); return false;});
$("#newyorkBtn").click(function() {window.open('http://www.yogoguide.com/newyork.html', '_self'); return false;});
 
//getFlashMovie('checker').checkItOut(yuser);
 
});
var ie;

function menuDelegate(){
	$("#parisBtn").mouseover(function() {
    $(this).css('background-color', '#99cc00');
	 $(this).css('cursor', 'pointer');
});
   $("#parisBtn").mouseout(function() {
    $(this).css('background-color', '#242424');
});
   	 $("#newyorkBtn").mouseover(function() {
   		$(this).css('background-color', '#ff9900');
		 $(this).css('cursor', 'pointer');
});
   $("#newyorkBtn").mouseout(function() {
    $(this).css('background-color', '#242424');
});
  


	$('#Col1').children('.btnOutline:eq(0)').unbind('click').click(function() {loginAppear();return false;});
	
	$('#Col1').children('.btnOutline:eq(1)').unbind('click').click(function() {window.open('http://www.yogoguide.com/register.html', '_blank');});
	$('#Col1').children('.btnOutline:eq(2)').unbind('click').click(function() {window.open('http://www.yogoguide.com/update.html', '_blank');});
	$('#Col1').children('.btnOutline:eq(3)').unbind('click').click(function() {window.open('http://www.yogoguide.com/forget.html', '_blank');});
	
	$('#Col2').children('.btnOutline:eq(0)').unbind('click').click(function() {window.open('http://www.yogoguide.com/who_are_we.html', '_blank')});
	$('#Col2').children('.btnOutline:eq(1)').unbind('click').click(function() {window.open('http://www.yogoguide.com/contact.html', '_blank')});
	$('#Col2').children('.btnOutline:eq(2)').unbind('click').click(function() {window.open('http://www.yogoguide.com/blog', '_blank')});
	$('#Col2').children('.btnOutline:eq(3)').unbind('click').click(function() {window.open('http://www.yogoguide.com/tutorials.html', '_blank')});
	
	$('#middleStuff').children('.btnOutline:eq(0)').hide();
	$('#middleStuff').children('.btnOutline:eq(1)').hide();
	//$('#middleStuff').children('.btnOutline:eq(2)').click(function() {menuDisable();frameReaction('http://www.faretothere.com', '#333333', 800)});
	$('#middleStuff').children('.btnOutline:eq(2)').hide();
	
	$('#Col3').children('.btnOutline:eq(0)').unbind('click').click(function() {});
	$('#Col3').children('.btnOutline:eq(1)').unbind('click').click(function() {window.open('http://www.yogoguide.com/list.html', '_blank')});
	$('#Col3').children('.btnOutline:eq(2)').unbind('click').click(function() {window.open('http://www.yogoguide.com/links.html', '_blank')});
	$('#Col3').children('.btnOutline:eq(3)').unbind('click').click(function() {window.open('http://www.yogoguide.com/press.html', '_blank')});
	
	$('#Col4').children('.btnOutline:eq(0)').unbind('click').click(function() {window.open('http://www.faretothere.com/airfare.php', '_blank')});
	$('#Col4').children('.btnOutline:eq(1)').unbind('click').click(function() {window.open('http://www.faretothere.com/hotel.php', '_blank')});
	$('#Col4').children('.btnOutline:eq(2)').unbind('click').click(function() {window.open('http://www.faretothere.com/car.php', '_blank')});
	$('#Col4').children('.btnOutline:eq(3)').unbind('click').click(function() {window.open('http://www.yogoguide.com/partners.html', '_blank')});
}
function menuDisable(){
	$('#Col1').children().unbind('click');
	$('#Col2').children().unbind('click');
	$('#middleStuff').children().unbind('click');
	$('#Col3').children().unbind('click');
	$('#Col4').children().unbind('click');
}


function getFlashMovie(movieName) {
				var isIE = navigator.appName.indexOf("Microsoft") != -1;
				return (isIE) ? window[movieName] : document[movieName];
			}

function javaScrptAlurt (message){
alert(message)
}

function reqesurl(loc){
	var w = window.open();
    w.opener = null;
    w.document.location = loc;
	
}

function menuRollOvers(){
	 $(".btnOutline").mouseover(function() {
    $(this).css('background-color', '#6699ff');
	 $(this).css('cursor', 'pointer');
});
   $(".btnOutline").mouseout(function() {
    $(this).css('background-color', '#333333');
});
   	 $(".socialOutline").mouseover(function() {
    $(this).css('border', '2px solid #fff');
});
   $(".socialOutline").mouseout(function() {
   $(this).css('border', '0px solid #fff');
   
});
   	 $(".div3").mouseover(function() {
    $(this).css('border', '1px solid #6699ff');
});
   $(".div3").mouseout(function() {
    $(this).css('border', '1px solid #666666');
});
}
var yuser = 'null';
function logInAction(user){
		 yuser = user;
			 $('#login').fadeOut('fast');
			 $("#instText").html('Welcome back '+yuser+'!  Thank you for logging in. When you&#39;re ready, simply choose a city on the right and have fun using yogoguide!  As always, let us know of any suggestions or listing ideas.  We&#39;re all ears!  Ready? Let&#39;s yogo!')
			 $("#instText").fadeIn('fast');
			 logoutAppear();
}
function loginBtnFade(){
	//$('#Col1').children('.btnOutline:eq(0)').unbind("click");
}

var posit;
function frameReaction(frameParam, frameColor, frameSize){
	if($("#mainLayout").height()!=1){
	posit = $("#footerBlock #pMain").offset();
	$("#welcomeText").hide();
	$("#mainLayout").css({'height':'1px', 'width':'1px'});
	//$("#footerBlock").css("margin-top", posit.top+"px");
	var pMainDown = posit.top+frameSize;
	$("#pMain").animate({"marginTop": "+="+pMainDown+"px"}, "slow");
	$("#gAdsMain #g1").animate({"marginTop": "+="+posit.top+"px"}, "slow");
	$("#gAdsMain #g2").animate({"marginTop": "+="+posit.top+"px"}, "slow", function() {callIframe(frameParam, frameColor, frameSize);});
	//$("#footerBlock").animate({"marginTop": "-="+posit.top+"px"}, "slow", function() {callIframe(frameParam, frameColor, frameSize);});
	}else{
		callIframe(frameParam, frameColor, frameSize);
	}
}

//login action on the login page as well as the main pages
function loginAppear(){
		   if($('#Col1').children('.btnOutline:eq(0)').children().attr('id')=='loginHidden'){
			 $('#login').fadeIn('fast');
			  $("#instText").fadeOut('fast');
			$('#Col1').children('.btnOutline:eq(0)').html('<img src="http://www.yogoguide.com/universal/menuBtns/loginH.png" id="loginVisible" border="0"/>');
			$('html, body').animate({scrollTop:0});
			menuRollOvers();
		 }else if($('#Col1').children('.btnOutline:eq(0)').children().attr('id')=='loginVisible'){
			 $('#login').fadeOut('fast');
			$("#instText").html('To visit as a guest, simply click one of the cities on the right, Paris or New York.  If you are a registered user feel free to login via the login button below.  If you are not a registered user why not become one?  It&#39;s free!');
			  $("#instText").fadeIn('fast');
			$('#Col1').children('.btnOutline:eq(0)').html('<img src="http://www.yogoguide.com/universal/menuBtns/login.png" id="loginHidden" border="0"/>');
			menuRollOvers();
	}else if($('#Col1').children('.btnOutline:eq(0)').children().attr('id')=='logoutVisible'){
	// $('#login').fadeIn('fast');
			$("#instText").fadeOut('fast', function(){logOutC();});
		 }
}

			
function logOutC(){
	document.getElementById('checker1').logOutConfirm(yuser);
}


//this makes the logout button appear and be active if the user had successfully logged in to the site
function logoutAppear(){
		$('#Col1').children('.btnOutline:eq(0)').html('<img src="http://www.yogoguide.com/universal/menuBtns/logout.png" id="logoutVisible" border="0"/>');
		menuRollOvers();
		$('.btnOutline:first').css('cursor', 'pointer');
}



function sendToJavaScript(val) {
			yuser = 'null';
			//$('#login').fadeOut('fast');
 			 $("#instText").html('Thank you '+val+'!  You have successfully logged out.  To visit as a guest, simply click one of the cities on the right or login in via the button below.');
 			 $("#instText").fadeIn('fast');
 			 $('#Col1').children('.btnOutline:eq(0)').html('<img src="http://www.yogoguide.com/universal/menuBtns/login.png" id="loginHidden" border="0"/>');
			$('html, body').animate({scrollTop:0});
			menuRollOvers();
}

function callIframe(url, bgcolour, heit) {
		
	var pMain = document.getElementById('pMain');
   var cont = document.getElementById('container');
   var contDiv = document.getElementById('containerDiv');
   var closeLinkDiv = document.getElementById('closeLinkDiv');
   var openWinDiv = document.getElementById('openWinDiv');
   var closeLinkDiv2 = document.getElementById('closeLinkDiv2');
   var openWinDiv2 = document.getElementById('openWinDiv2');
   var u = url;
   var bg = bgcolour;
   var h = heit;
 
   
	function scrollY() {return window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;}

  //main menu fades out
  $(pMain).fadeOut('fast', function() {
								 
  if(!contDiv.style.height || contDiv.style.height=='0px'){
	  	
	$(contDiv).hide().fadeIn("fast", function(){setTimeout ('$("html, body").animate({scrollTop: $("#containerDiv").offset().top}, 800)', 100);});
	
	var conDivHite = h+75;
    contDiv.style.height = conDivHite+'px';
	contDiv.style.background=bg;
	contDiv.style.border='1px solid #666666';
	
	$(pMain).css('margin-top', conDivHite+750+'px');
	
	$(pMain).fadeIn(1, function() {});///closes pMain fadeIn					 
						
	var closeLink=document.createElement('a');
	closeLink.id = "closeLink"
	closeLink.setAttribute('href', 'javascript:void');
	var closeLink2=document.createElement('a');
	closeLink2.id = "closeLink2"
	closeLink2.setAttribute('href', 'javascript:void');
	
	
	closeWin = document.createElement('input');
	closeWin.setAttribute('type', 'image');
    closeWin.setAttribute('src', 'http://www.yogoguide.com/universal/frame/closeWinL.png');
	closeWin.setAttribute("align","right");
	$(closeWin).click(function(){
		try{cont.removeChild(myImagePR);}catch(err){};
			returnReset('regular');
								});
		
	closeWin2 = document.createElement('input');
	closeWin2.setAttribute('type', 'image');
    closeWin2.setAttribute('src', 'http://www.yogoguide.com/universal/frame/closeWinL.png');
	closeWin2.setAttribute("align","right");

	$(closeWin2).click(function(){
							try{cont.removeChild(myImagePR);}catch(err){};
			returnReset('regular');
								});
	
	var conBtnsHite = heit+45+"px";
	
	closeLink2.appendChild(closeWin2);
	
	closeLinkDiv2.style.marginTop = conBtnsHite;
	
	closeLinkDiv2.appendChild(closeLink2);
		
	closeLink.appendChild(closeWin);
	
	closeLinkDiv.appendChild(closeLink);
	
	
		
	var openWin=document.createElement('a');
	openWin.id = "openWin"
	openWin.setAttribute('href', 'javascript:void()');
	openWin.setAttribute("target", "_blank");

	openImage = document.createElement('input');
	openImage.setAttribute('type', 'image');
    openImage.setAttribute('src', 'http://www.yogoguide.com/universal/frame/openNewWin.png');
	openImage.setAttribute("align","left");
	openImage.onclick = function (evt) {
			window.open(url, '_blank');
			return false;
		}
		
	var openWin2=document.createElement('a');
	openWin2.id = "openWin2"
	openWin2.setAttribute('href', 'javascript:void()');
	openWin2.setAttribute("target", "_blank");

	openImage2 = document.createElement('input');
	openImage2.setAttribute('type', 'image');
    openImage2.setAttribute('src', 'http://www.yogoguide.com/universal/frame/openNewWin.png');
	openImage2.setAttribute("align","left");
	openImage2.onclick = function (evt) {
			window.open(url, '_blank');
			return false;
		}

	openWinDiv2.style.marginTop = conBtnsHite;
	
	openWin2.appendChild(openImage2);
	
	openWinDiv2.appendChild(openWin2);

	openWin.appendChild(openImage);
	
	openWinDiv.appendChild(openWin);
	
	var iFrameObj = document.createElement('IFRAME');
    iFrameObj.id = 'uniqueFrame';
	iFrameObj.name = 'iframer';
    iFrameObj.src = url;
	iFrameObj.width = 800;
	iFrameObj.height = heit;
	iFrameObj.frameBorder = 0;
	iFrameObj.allowTransparency= 0;
	
	var urlLoad = document.body.appendChild(iFrameObj);
	
	var myImagePR = new Image;
	if(bg=="#333333"){
		myImagePR.src = "http://www.yogoguide.com/universal/toto/preloaderB.gif";
	}else if(bg=="#FFFFFF"){
		myImagePR.src = "http://www.yogoguide.com/universal/toto/preloaderW.gif";
	}else{
		myImagePR.src = "http://www.yogoguide.com/universal/toto/preloaderB.gif";
	}
	
	cont.appendChild(myImagePR);
	cont.appendChild(urlLoad);
	 $('#uniqueFrame').css('display', 'none');
	  $('#uniqueFrame').load(function()
	  {
	    $('#uniqueFrame').css('display', 'block');
	    	cont.removeChild(myImagePR);
			menuDelegate();
			if(h==1222){
				contDiv.style.height = $("#uniqueFrame").contents().find(".div1").height()+100+"px";
				iFrameObj.height = $("#uniqueFrame").contents().find(".div1").height()+30+"px";
				openWinDiv2.style.marginTop = $("#uniqueFrame").contents().find(".div1").height()+75+"px";
				closeLinkDiv2.style.marginTop = $("#uniqueFrame").contents().find(".div1").height()+75+"px";
				$(pMain).css('margin-top', $("#uniqueFrame").contents().find(".div1").height()+260+'px');
			}
	  });
	  
	if (ie!='ie6' || ie!='ie7'){
			$(contDiv).css('margin-left', '-300px');
		}
	
	 if(url=='http://www.yogoguide.com/blog'){
		$(contDiv).width(1005);
		$('#uniqueFrame').width(995);
		$(contDiv).css('margin-left', -130);
		//$('.containerIE').css('margin-left', 0);
	}else if(url=='http://www.faretothere.com'){
		$(contDiv).width(1020);
		$('#uniqueFrame').width(1015);
		$(contDiv).css('margin-left', -140);
		//$('.containerIE').css('margin-left', 0);
	}else if(url=='http://www.faretothere.com/airfare.php'){
		$(contDiv).width(1020);
		$('#uniqueFrame').width(1015);
		$(contDiv).css('margin-left', -140);
		//$('.containerIE').css('margin-left', 0);
	}else if(url=='http://www.faretothere.com/hotel.php'){
		$(contDiv).width(1020);
		$('#uniqueFrame').width(1015);
		$(contDiv).css('margin-left', -140);
		//$('.containerIE').css('margin-left', 0);
	}else if(url=='http://www.faretothere.com/car.php'){
		$(contDiv).width(1020);
		$('#uniqueFrame').width(1015);
		$(contDiv).css('margin-left', -90);
		//$('.containerIE').css('margin-left', 0);
	}else{
		$(contDiv).width(815);
		$('#uniqueFrame').width(800);
		$(contDiv).css('margin-left', -35);
		//$('.containerIE').css('margin-left', 0);
	}
	
	}else{
		var namer = document.getElementById('uniqueFrame');
		var urler = url;
		if(namer.src == urler){
	 		scrollUp('closeFast');
		}else{
	 		scrollUp('reopen');
			setTimeout (function(){callIframe(u, bg, h)}, 1000 );
		}
	}
	 
	});//main menu fades out
}

//removes iframe when user clicks the close button
function returnReset(whatKind){
		var cont = document.getElementById("container");
		var iframeId = document.getElementById("uniqueFrame");
	 	cont.removeChild(iframeId);
 	   	var pMain = document.getElementById('pMain');
	
        var cont = document.getElementById("container");
		var contDiv = document.getElementById('containerDiv');
		var closeLink = document.getElementById('closeLink');
		var openWin = document.getElementById('openWin');
		var closeLinkDiv = document.getElementById('closeLinkDiv');
		var openWinDiv = document.getElementById('openWinDiv');
		var closeLink2 = document.getElementById('closeLink2');
		var openWin2 = document.getElementById('openWin2');
		var closeLinkDiv2 = document.getElementById('closeLinkDiv2');
		var openWinDiv2 = document.getElementById('openWinDiv2');
   		var iframeId = document.getElementById("uniqueFrame");
		closeLinkDiv.removeChild(closeLink);
		openWinDiv.removeChild(openWin);
		closeLinkDiv2.removeChild(closeLink2);
		openWinDiv2.removeChild(openWin2);
			$(contDiv).fadeOut("fast", function() {
						contDiv.style.height='0px';
						contDiv.style.background='#333333';
						contDiv.style.border='1px solid #333333';
						if(whatKind!='reopen'){
							$("#gAdsMain #g1").animate({"marginTop": "-="+posit.top+"px"}, "slow");
							$("#gAdsMain #g2").animate({"marginTop": "-="+posit.top+"px"}, "slow");
							$("#footerBlock").animate({"marginTop": "+="+posit.top+"px"}, "slow", function(){
																												$("#mainLayout").css({'height':'526px', 'width':'1000px'});
																												$("#footerBlock").css('margin-top','0px');
																												$(pMain).css('margin-top', '140px');
																												$(pMain).hide().fadeIn('fast');
																												menuDelegate();
																															  });
						}
						});
}

//contact email
function SplashcheckSend(){
var ajaxRequest;
try{ajaxRequest=new XMLHttpRequest();}catch(e){try{ajaxRequest=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser broke!");return false;}}}
var messager=escape(document.sendform.message.value);
var emailr=document.sendform.email.value;
var usrnamer=document.sendform.usrname.value;
var placer=document.sendform.place.value;
if(emailr==document.sendform.email.defaultValue){ alert('please leave your email'); return;}
var url="http://www.yogoguide.com/contactForm/contactServelet.php?message="+messager+"&email="+emailr+"&usrname="+usrnamer+"&place="+placer;
ajaxRequest.onreadystatechange=function()
{if(ajaxRequest.readyState==4)
{var allowed=ajaxRequest.responseText;
alert(allowed);
document.sendform.reset();
return;}}
ajaxRequest.open("GET",url,true);ajaxRequest.send(null);}
