function newImage(arg) 

{

	rslt = new Image();

	rslt.src = arg;

	return rslt;

}





var	youtube = newImage("img/img-connected-youtube.gif");

var	youtube_on = newImage("img/img-connected-youtube-on.gif");



var	facebook = newImage("img/img-connected-facebook.gif");

var	facebook_on = newImage("img/img-connected-facebook-on.gif");



var	twitter = newImage("img/img-connected-twitter.gif");

var	twitter_on = newImage("img/img-connected-twitter-on.gif");





function swapON(id){

document.getElementById(id).src=eval(id+'_on').src;

}



function swapOFF(id){

document.getElementById(id).src=eval(id).src;

}





function setBlockBg(obj,last,logos){

	obj.className="block over"+" "+last;

	document.getElementById(logos+'-logos').className='smallshare';

}



function removeBlockBg(obj,last,logos){

	obj.className="block "+" "+last;

	document.getElementById(logos+'-logos').className='smallshare hidden';

}





function swapImage(source_id,newUrl){

	document.getElementById(source_id).src=newUrl;

}





function loadAjaxPhoto(pid,aid,skip,base){

					var dest_div='ajaxcontainer';



					obj = document.getElementById(dest_div);

					obj.innerHTML = "<div id=\"ajaxpos\"><img src=\"img/loader.gif\" /></div>"; 

					document.location.href=base+'#'+skip;

					



					AjaxRequest.get(

					  {

					    'url':'incs/ajax/photo.php?pid='+pid+'&aid='+aid+'&skip='+skip+'&base='+base,'onSuccess':function(req)

							{ 

								obj = document.getElementById(dest_div);

								obj.innerHTML = req.responseText; 

								initFB();

							}

					    ,'timeout':10000

					    ,'onTimeout':function(req){ loadAjaxPhoto(pid,aid,skip,base); }

					  }

					);

}





function loadAjaxPhoto2(pid,aid,skip,base){

					var dest_div='ajaxcontainer';



					obj = document.getElementById(dest_div);

					obj.innerHTML = "<div id=\"ajaxpos\"><img src=\"img/loader.gif\" /></div>"; 

					document.location.href=base+'#'+skip;

					



					AjaxRequest.get(

					  {

					    'url':'incs/ajax/photo2.php?pid='+pid+'&aid='+aid+'&skip='+skip+'&base='+base,'onSuccess':function(req)

							{ 

								obj = document.getElementById(dest_div);

								obj.innerHTML = req.responseText; 

								initFB();

							}

					    ,'timeout':10000

					    ,'onTimeout':function(req){ loadAjaxPhoto2(pid,aid,skip,base); }

					  }

					);

}





function initFB(){



            window.fbAsyncInit = function() {

                FB.init({appId: '180990431914215', status: true, cookie: true, xfbml: true});

                /* All the events registered */

                FB.Event.subscribe('auth.login', function(response) {

                    // do something with response

//                    login();

                });

                FB.Event.subscribe('auth.logout', function(response) {

                    // do something with response

//                    logout();

                });

            };

  (function() {

                var e = document.createElement('script');

                e.type = 'text/javascript';

                e.src = document.location.protocol +

                    '//connect.facebook.net/en_US/all.js';

                e.async = true;

                document.getElementById('fb-root').appendChild(e);

            }());



//            function login(){

//                document.location.href = "http://empireevents.com/";

//            }

//            function logout(){

//                document.location.href = "http://emp[ire";

//            }





}



function validateEmail(field){

	var emailReg = "^[a-z|0-9]+([\-|_|\.]?[a-z|0-9|_]+)*@[a-z|0-9]+([\-|\.]+[a-z|0-9]+)+$";

	var regex = new RegExp(emailReg);

	if (!regex.test(document.getElementById(field).value.toLowerCase()))

	{

		return false;

	}

return true;

}





var wnd = null;



function open_window(page_url, wid, hei)

{

	var wnd_height = (hei) ? hei : 400;

	var wnd_width = (wid) ? wid : 600;

	var wnd_left = (screen.width - wid)/2;

	var wnd_top = (screen.height - hei)/2;

	if(wnd)

	{

		wnd = window.open(page_url, "preview_wnd", "location=no,menubar=no,personalbar=no,scrollbars=yes,status=no,toolbar=no,width="+wnd_width+",height="+wnd_height+",left="+wnd_left+",top="+wnd_top);

		wnd.focus();

	}

	else

	{

		wnd = window.open(page_url, "preview_wnd", "location=no,menubar=no,personalbar=no,scrollbars=yes,status=no,toolbar=no,width="+wnd_width+",height="+wnd_height+",left="+wnd_left+",top="+wnd_top);

	}

}





	function openShare(url){

		open_window('http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4cb2eaaf7f61aca1&url='+url+'&title=Empire%20Events', 520, 700);

		

	}





function validateContact(form){



                var errstring='';

                var flag=1;



	                if(document.getElementById('fname').value.length<=0 || document.getElementById('fname').value=='FIRST NAME') { errstring=errstring+'- First Name\n'; flag=0; }

			if(!validateEmail('email')) { errstring=errstring+'- Email\n'; flag=0; }

	                if(document.getElementById('subject').selectedIndex==0) { errstring=errstring+'- Subject\n'; flag=0; }

	                if(document.getElementById('comments').value.length<=0 || document.getElementById('comments').value=='COMMENTS') { errstring=errstring+'- Comments\n'; flag=0; }



                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);

                               	else  {

					if(document.getElementById('lname').value=='LAST NAME') document.getElementById('lname').value='';

					if(document.getElementById('phone').value=='PHONE') document.getElementById('phone').value='';

					form.submit();

				}

				return false;

}



var vipemail;



function validateVip(){

                var errstring='';

                var flag=1;



			if(!validateEmail('vip_email')) { errstring=errstring+'- Email\n'; flag=0; }



                              if(flag==0) alert('Please fill out these fields correctly:\n\n'+errstring);

                               	else  {

					vipemail=document.getElementById('vip_email').value;

					getformpostreturn("vipsignup.php",'vip');

					resetForm('vip');

				}

				return false;

}





function getRequestBody(oForm) { 

     var aParams = new Array();

     for(var i = 0; i < oForm.elements.length; i++) {

         var sParam = encodeURIComponent(oForm.elements[i].name);

         sParam += "=";

         sParam += encodeURIComponent(oForm.elements[i].value);

         aParams.push(sParam);

     }

     return aParams.join("&");

 }



function resetForm(formid){

document.getElementById(formid).reset();

}







 function getformpost(script,form) {

         

         var nameRequestForm = document.getElementById(form);

         var post_arg = getRequestBody(nameRequestForm);

         

					AjaxRequest.post(

					  {

					    'queryString': post_arg,

					    'url':'incs/ajax/'+script,'onSuccess':function(req)

							{ 

//								var dest_div='ajaxcontainer';

//								obj = document.getElementById(dest_div);

								alert(req.responseText); 

							}

					    ,'timeout':30000

					    ,'onTimeout':function(req){ getformpost(script,form); }

					  }

					);

}





 function getformpostreturn(script,form) {

         

         var nameRequestForm = document.getElementById(form);

         var post_arg = getRequestBody(nameRequestForm);

         

					AjaxRequest.post(

					  {

					    'queryString': post_arg,

					    'url':'incs/ajax/'+script,'onSuccess':function(req)

							{ 

								if(req.responseText.indexOf('database')==-1) {

                                                                 askinfo(vipemail);

								} else {

								 	alert(req.responseText);

								}

								

							}

					    ,'timeout':30000

					    ,'onTimeout':function(req){ getformpostreturn(script,form); }

					  }

					);



 }



function askinfo(email){

	openAsk(email);

}





function checkforemail(email){



					AjaxRequest.get(

					  {

					    'url':'incs/ajax/checkisemail.php?email='+email,'onSuccess':function(req)

							{ 

								if(req.responseText.indexOf('1')!=-1)  return 1; else return 0;

								

							}

					    ,'timeout':10000

					    ,'onTimeout':function(req){ checkforemail(email); }

					  }

					);

}







 function getformpost2(script,form) {

         

         var post_arg = getRequestBody(form);

		alert(post_arg);

					AjaxRequest.post(

					  {

					    'queryString': post_arg,

					    'url': script,'onSuccess':function(req)

							{ 

//								var dest_div='ajaxcontainer';

//								obj = document.getElementById(dest_div);

								alert(req.responseText); 

							}

					    ,'timeout':30000

					    ,'onTimeout':function(req){ getformpost2(script,form); }

					  }

					);



 }







function getPageSize(){

	

	var xScroll, yScroll;

	

	if (window.innerHeight && window.scrollMaxY) {	

		xScroll = document.body.scrollWidth;

		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac

		xScroll = document.body.scrollWidth;

		yScroll = document.body.scrollHeight;

	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari

		xScroll = document.body.offsetWidth;

		yScroll = document.body.offsetHeight;

	}

	

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer

		windowWidth = self.innerWidth;

		windowHeight = self.innerHeight;

	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

		windowWidth = document.documentElement.clientWidth;

		windowHeight = document.documentElement.clientHeight;

	} else if (document.body) { // other Explorers

		windowWidth = document.body.clientWidth;

		windowHeight = document.body.clientHeight;

	}	

	

	// for small pages with total height less then height of the viewport

	if(yScroll < windowHeight){

		pageHeight = windowHeight;

	} else { 

		pageHeight = yScroll;

	}



	// for small pages with total width less then width of the viewport

	if(xScroll < windowWidth){	

		pageWidth = windowWidth;

	} else {

		pageWidth = xScroll;

	}





	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;

}



function getBodyScrollTop()

{

	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);

}



function getBodyScrollLeft()

{

	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);

}



function getClientWidth()

{

  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;

}



function getClientHeight()

{

  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;

}



function getClientCenterX()

{

		var arrayPageSize = getPageSize();

		var hei=arrayPageSize[1];

		var wid=document.body.scrollWidth;



	return parseInt(wid/2);

}



function getClientCenterY()

{

		var arrayPageSize = getPageSize();

		var hei=arrayPageSize[1];

		var wid=document.body.scrollWidth;



	return parseInt(hei/2)+getBodyScrollTop();

}





	function openRSVP(id)

		{

		var width=700;

		var height=450;

		var arrayPageSize = getPageSize();

		var hei=arrayPageSize[1];

		var wid=document.body.scrollWidth;



		var half_width=width/2;

		var half_height=height/2;



		document.getElementById('shaded').style.height=hei+"px";

		document.getElementById('shaded').style.width=wid+"px";



		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height; else var tp=10;



		tp=220;



		document.getElementById('urlzone').src="reservation.php?id="+id;



		document.getElementById('infoiframe2_div').style.top=tp+"px";

		document.getElementById('infoiframe2_div').style.left=(getClientCenterX()-half_width)+"px";



		document.getElementById('infoiframe2_div').style.width=width+"px";

		document.getElementById('infoiframe2_div').style.height=height+"px";

	

		document.getElementById('shaded').className="shaded_vis";

		document.getElementById('infoiframe2_div').className="infoiframe_visible";

		}





	function openAsk(email)

		{

		var width=450;

		var height=350;

		var arrayPageSize = getPageSize();

		var hei=arrayPageSize[1];

		var wid=document.body.scrollWidth;



		var half_width=width/2;

		var half_height=height/2;



		document.getElementById('shaded').style.height=hei+"px";

		document.getElementById('shaded').style.width=wid+"px";



		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height; else var tp=10;



		tp=270;



		document.getElementById('emailzone').src="moreinfovip.php?email="+email;



		document.getElementById('infoiframe3_div').style.top=tp+"px";

		document.getElementById('infoiframe3_div').style.left=(getClientCenterX()-half_width)+"px";



		document.getElementById('infoiframe3_div').style.width=width+"px";

		document.getElementById('infoiframe3_div').style.height=height+"px";

	

		document.getElementById('shaded').className="shaded_vis";

		document.getElementById('infoiframe3_div').className="infoiframe_visible";

		}





	function closeinfo()

		{

			document.getElementById('shaded').className="shaded_hid";

			document.getElementById('infoiframe2_div').className="infoiframe_hidden";

			document.getElementById('urlzone').src="blank.html";

		}



	function closeask()

		{

			document.getElementById('shaded').className="shaded_hid";

			document.getElementById('infoiframe3_div').className="infoiframe_hidden";

			document.getElementById('emailzone').src="blank.html";

		}





	function openFacebookRSVP(id)
		{
		var width=700;
		var height=500;
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=(hei)+"px";
		document.getElementById('shaded').style.width=wid+"px";

		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height; else var tp=10;

		tp=220;

		document.getElementById('urlzone').src="fb_reservation.php?id="+id;

		document.getElementById('infoiframe2_div').style.top=tp+"px";
		document.getElementById('infoiframe2_div').style.left=(getClientCenterX()-half_width)+"px";

		document.getElementById('infoiframe2_div').style.width=width+"px";
		document.getElementById('infoiframe2_div').style.height=height+"px";
	
		document.getElementById('shaded').className="shaded_vis";
		document.getElementById('infoiframe2_div').className="infoiframe_visible";
		}


	function forwardFriend(hash,uid,path)
		{
		var width=700;
		var height=500;
		var arrayPageSize = getPageSize();
		var hei=arrayPageSize[1];
		var wid=document.body.scrollWidth;

		var half_width=width/2;
		var half_height=height/2;

		document.getElementById('shaded').style.height=(hei)+"px";
		document.getElementById('shaded').style.width=wid+"px";

		if((getClientCenterY()-half_height)>0) var tp=getClientCenterY()-half_height; else var tp=10;

		tp=220;

		document.getElementById('urlzone').src="fb_forward.php?hash="+hash+"&uid="+uid+"&path="+path;

		document.getElementById('infoiframe2_div').style.top=tp+"px";
		document.getElementById('infoiframe2_div').style.left=(getClientCenterX()-half_width)+"px";

		document.getElementById('infoiframe2_div').style.width=width+"px";
		document.getElementById('infoiframe2_div').style.height=height+"px";
	
		document.getElementById('shaded').className="shaded_vis";
		document.getElementById('infoiframe2_div').className="infoiframe_visible";
		}



var wnd = null;



function openTagger(image_path, pid, wid, hei)

{



	var hei2=hei+20;

	var wid2=wid+250;



	var wnd_height = (hei2) ? hei2 : 400;

	var wnd_width = (wid2) ? wid2 : 600;

	var wnd_left = (screen.width - wid2)/2;

	var wnd_top = (screen.height - hei2)/2;



	



	if(wnd)

	{

		wnd = window.open('image_tag2.php?image='+image_path+'&pid='+pid+'&image_width='+wid+'&image_height='+hei, "preview_wnd", "location=no,menubar=no,personalbar=no,scrollbars=no,status=no,toolbar=no,width="+wnd_width+",height="+wnd_height+",left="+wnd_left+",top="+wnd_top);

		wnd.focus();

	}

	else

	{

		wnd = window.open('image_tag2.php?image='+image_path+'&pid='+pid+'&image_width='+wid+'&image_height='+hei, "preview_wnd", "location=no,menubar=no,personalbar=no,scrollbars=no,status=no,toolbar=no,width="+wnd_width+",height="+wnd_height+",left="+wnd_left+",top="+wnd_top);

	}

}







	function eventgo(what){

		document.location.href="events.php?hash="+what;

	}


