var del, del2, oldresize;
del=null;
del2=null;

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+$/g,"");
		if (x==c_name)return unescape(y);
	}
}
 
 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 renew() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	$(del).css({
		'top': ((myHeight/2)-150) + pageYOffset,
		'left': (myWidth/2)-370,
	});
}

function closeBox() {
	if(del!=null) {
		del2.onclick=null;
	//	setCookie("dnshowlikebox", document.getElementById("dontshowcheck").checked, 365);

		$(del).fadeOut(1000, function() {
			document.body.removeChild(del);
			del=null;
			window.onresize=oldresize;
			window.onscroll=oldscroll;
		});
		$(del2).fadeOut(1000, function() {
			document.body.removeChild(del2);
			del2=null;
		});
	} else {
		alert("Kutu zaten çıkmadı ki.");
	}
	return false;
}

function showBox(l) {
	var atmp, btmp, myWidth = 0, myHeight = 0, ing, il;
	if(del!=null) return ;

	il=0;
	il=window.location.hostname.indexOf('.');
	if(il!=-1) {
		if(window.location.hostname.substring(0,3)=='eng') {
			ing=1;
		}
	}

	del2=document.createElement("div");
	del2.className="backgroundPopup";
	del2.onclick=closeBox;

	del=document.createElement("div");
	del.className="likex2";

	atmp=document.createElement("a");
	atmp.className="likeFbLink";
	atmp.href="http://www.facebook.com/EliteWorldHotels";
	del.appendChild(atmp);

	atmp=document.createElement("a");
	atmp.className="linkTwLink";
	atmp.href="http://twitter.com/Eliteworldhotel";
	del.appendChild(atmp);

	atmp=document.createElement("a");
	atmp.className="likeGpLink";
	atmp.href="http://plus.google.com/u/0/103500325479544747433/posts";	
	del.appendChild(atmp);

	atmp=document.createElement("div");
	atmp.className="lkl2";
	btmp=document.createElement("a");
	btmp.href="#";
	btmp.onclick=closeBox;
	atmp.appendChild(btmp);
	del.appendChild(atmp);

	atmp.href="http://plus.google.com/u/0/103500325479544747433/posts";
	atmp.style.left=315;
	del.appendChild(atmp);

	atmp=document.createElement("div");
	atmp.className="alt";

	btmp=document.createElement("div");
	btmp.className="fb";
	btmp.innerHTML="<iframe src=\"http://www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FEliteWorldHotels&amp;send=false&amp;layout=button_count&amp;width=98&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=verdana&amp;height=21&amp;appId=140892909342865\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:98px; height:21px;\" allowTransparency=\"true\"></iframe>";
	atmp.appendChild(btmp);	

	btmp=document.createElement("div");
	btmp.className="tw";
	if(ing) btmp.innerHTML="<iframe scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" src=\"http://platform.twitter.com/widgets/follow_button.html#_=1322143862332&amp;button=blue&amp;id=twitter_tweet_button_0&amp;lang=en&amp;screen_name=Eliteworldhotel&amp;show_count=false\" class=\"twitter-follow-button\" style=\"width: 150px; height: 20px;\" title=\"\"></iframe>";
	else btmp.innerHTML="<iframe scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" src=\"http://platform.twitter.com/widgets/follow_button.html#_=1322143862332&amp;button=blue&amp;id=twitter_tweet_button_0&amp;lang=tr&amp;screen_name=Eliteworldhotel&amp;show_count=false\" class=\"twitter-follow-button\" style=\"width: 150px; height: 20px;\" title=\"\"></iframe>";
	atmp.appendChild(btmp);	

	btmp=document.createElement("div");
	btmp.className="tw";
	btmp.innerHTML="<a href=\"http://plus.google.com/u/0/103500325479544747433/posts\" target=\"_blank\"><img src=\"images/design/googlelike.png\" border=\"0\" width=\"65\" alt=\"Google+\" /></a>";
	atmp.appendChild(btmp);
	del.appendChild(atmp);

/*
	atmp=document.createElement("div");
	atmp.className="gosterme";
	btmp=document.createElement("label");

	if(ing) btmp.innerHTML="<input type=\"checkbox\" name=\"dontshowcheck\" id=\"dontshowcheck\" />Don't show this page";
	else btmp.innerHTML="<input type=\"checkbox\" name=\"dontshowcheck\" id=\"dontshowcheck\" />Bu sayfayı bir daha gösterme";

	atmp.appendChild(btmp);
	del.appendChild(atmp);
*/
 
	del.style.display='none';

	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }

	$(del).css({
		'top': ((myHeight/2)-150) + pageYOffset,
		'left': (myWidth/2)-370,
	});

	oldresize=window.onresize;
	oldscroll=window.onscroll;

	window.onresize=renew;
	window.onscroll=renew;

	document.body.insertBefore(del, document.body.firstChild);
	document.body.insertBefore(del2, document.body.firstChild);

	$(del2).fadeTo(1000, 0.7);
	$(del).fadeIn(1000);
}

