/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupScreenshot").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupScreenshot").fadeOut("slow");
		popupStatus = 0;
	}
	//clearInterval(t);
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupScreenshot").height();
	var popupWidth = $("#popupScreenshot").width();
	//centering
	$("#popupScreenshot").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

function popupWin(){
	this.Title;
	this.ContentText;
}

var t1, t2, divTag;
t1 = 1;
t2 = 2;

function rollPic() {
	$(divTag[t2]).fadeIn(1500);
	$(divTag[t1]).fadeOut(1500);
	t1 = t1 + 1;
	t2 = t2 + 1;
	if (t1 >= divTag.length) t1=0;
	if (t2 >= divTag.length) t2=0;
	setTimeout(rollPic,4500);
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#ae, #logos #storybrush, #logos #tcp, #logos #citydeli, #logos #dqs").click(function(){
		//alert(this.id);
		$("#popupScreenshot h1").html(eval(this.id).Title);
		$("#popupScreenshot #popupArea").html(eval(this.id).ContentText);
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupScreenshotClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
});

var ae = new popupWin();
ae.Title = "All Effort Limited";
ae.ContentText = "<div align=\"left\"><p>\"We have worked with All Effort Limited for several years now. They work hard to keep up with the search engine game and have managed to drive us a lot of traffic and conversions over the years.\"</p><p>Bryan Stafford<br />Vice President<br />Booksfree.com</p><p align=\"center\" style=\"font-weight: bold; font-size:16px; text-decoration:underline; \">Clients We Serve</p><div id=\"clientsLogo\" style=\"vertical-align:middle; margin-top:20px; \" align=\"center\"><div><img src=\"images/logo_worktree.gif\"></div><div><img src=\"images/logo_megafriends.jpg\"></div><div><img src=\"images/logo_css.gif\"></div><div><img src=\"images/logo_netmagazines.jpg\"></div><div><img src=\"images/logo_onetravel.jpg\"></div><div><img src=\"images/logo_hs.gif\"></div><div><img src=\"images/logo_insure.gif\"></div><div><img src=\"images/logo_thenerds.jpg\"></div><div><img src=\"images/logo_wrapables.gif\"></div></div><script type=\"text/javascript\">divTag = $(\"#clientsLogo div\");rollPic();</script><div align=\"center\" style=\"color: #0000FF; text-decoration:underline; margin-top: 120px; \"><a href=\"mailto:contact@alleffort.com\" style=\"color:#0000FF; \">Contact Us For a RISK-FREE Consultation</a></div></div>"

var storybrush = new popupWin();
storybrush.Title = "Story Brush";
storybrush.ContentText = "<div align=\"center\"><img src=\"images/site_storybrush.jpg\"></div><div class=\"site-description\"><div class=\"site-link\"><a href=\"http://www.storybrush.com/\" target=\"_blank\">www.storybrush.com</a></div>Digital images to oil paintings direct from China.</div>";

var tcp = new popupWin();
tcp.Title = "The China Perspective";
tcp.ContentText = "<div align=\"center\"><img src=\"images/site_tcp.jpg\"></div><div class=\"site-description\"><div class=\"site-link\"><a href=\"http://www.thechinaperspective.com/\" target=\"_blank\">www.thechinaperspective.com</a></div>A leading source of China business news, analysis and statistics.</div>";

var citydeli = new popupWin();
citydeli.Title = "City Deli";
citydeli.ContentText = "<div align=\"center\"><img src=\"images/site_citydeli.jpg\"></div><div class=\"site-description\"><div class=\"site-link\"><a href=\"http://www.citydeli.cn/\" target=\"_blank\">www.citydeli.cn</a></div>Serving authentic deli style food in Shanghai.</div>";

var dqs = new popupWin();
dqs.Title = "Direct Quality Sourcing";
dqs.ContentText = "<div align=\"center\"><img src=\"images/site_dqs.jpg\"></div><div class=\"site-description\"><div class=\"site-link\"><a href=\"http://www.directqualitysourcing.com/\" target=\"_blank\">www.directqualitysourcing.com</a></div>Providing sourcing and logistics services in the promotional items industry.</div>";
