// home page scripts
var clickedPromo;
function showCatalogSelector(promoInput, event){            
	var divCatalogSelector = document.getElementById("catalogselector");
	var divContent = "Loading. . .";
	divCatalogSelector.innerHTML = divContent;
	clickedPromo = promoInput;
	repositionCatalogSelector(event);
}
function getCatalogSelector(){
	var divCatalogSelector;
	if (document.getElementById){
			divCatalogSelector = document.getElementById("catalogselector");
	}
	else if (document.all){
			divCatalogSelector = document.all.catalogselector;
	}
	return divCatalogSelector;
}
function repositionCatalogSelector(event){
	var x=0 ;
	var y=0;
	var IE = document.all?true:false;
	if (IE) { // MSIE
		var ScrollTop = document.body.scrollTop;
		var ScrollLeft = document.body.scrollLeft;
		if (ScrollTop == 0)
		{	
			 if (window.pageYOffset){
				ScrollTop = window.pageYOffset;
				  ScrollLeft = window.pageXOffset;
			 }
			 else{
				ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
				  ScrollLeft = (document.body.parentElement) ? document.body.parentElement.scrollLeft : 0;
			 }
		}
		x = event.clientX+ScrollLeft;
		y = event.clientY+ScrollTop;
	} else { // Netscape, etc.
		x = event.pageX;
			  y = event.pageY;
	}
	var divCatalogSelector = getCatalogSelector();
	if (divCatalogSelector!=null){		//if condition added
		divCatalogSelector.style.left = (x - 120 - 5) + "px";
		divCatalogSelector.style.top = y + "px";
		loadCatalogSelector();
	}
}
function closeClicked(closeButton, e){
	//new Effect.SlideUp("catalogselectorcontent");
	$("#catalogselector").slideUp();
	trackGoogleEvent("content_"+clickedPromo.id,'click',closeButton.title,1);
	//return false;
	if (e && e.preventDefault){
		e.preventDefault(); // DOM style
		return false; // IE style
	}
	else {
		return false;
	}
}	
function loadCatalogSelector(){
	var category = clickedPromo.value;
	if(category){
		getCatalogSelector().innerHTML = "<div id=\"catalogselectorcontent\">Loading .</div>";
		getCatalogSelector().style.display = "block";
		$.ajax({url:"/bgs/abc.html",success:function(result){$("#catalogselectorcontent").html(result);}});
	}
}
function showData1(){
	getCatalogSelector().innerHTML = request.responseText;
	$("#catalogselectorcontent").hide();
	document.getElementById("catalogselectorcontent").style.borderWidth = "1px";
	document.getElementById("catalogselectorcontent").style.borderStyle = "solid";
	document.getElementById("catalogselectorcontent").style.borderColor = "#8e5c8d";
	//new Effect.Appear("catalogselectorcontent");
	$("#catalogselectorcontent").slideDown(700);
}
function gotoCategory(categorySelect){
	var affiliatePrefix = "";
	var categoryPage = affiliatePrefix + "/gifts/send-corporate-gifts-to-" +  categorySelect.options[categorySelect.selectedIndex].value.split("_")[1];
	document.location.href = categoryPage;
}

var praises = new Array();
praises[0] = new Array("Your service, it was excellent and my aunt in Berlin said to me that the snacks were very good.", "Alicia Guerrero");
praises[1] = new Array("Thanks giftsnideas... tulips were delivered fresh just in time... You have been a great help. We are in great terms now! Will return to you for more!",  "Andre");
praises[2] = new Array("I had given the wrong address and so never expected for the parcel to be redirected successfully, as it eventually was. Thank you once again.", "Miss Esther Ditzel");
praises[3] = new Array("Thank you for the instructions you provided in the email. Greatly appreciate your prompt response!",  "Debbie");
praises[4] = new Array("I found John who works at the customer service extremely helpful and very friendly, gladly appreciate such effective staff on board.", "Keith Oliver");
var currentPraiseColor = 255;
var currentPraiseIndex = -1;
var praiseColorStep = 1;
var spanPraise;
var spanCustomer;
var praiseTimer;
var praiseSpeed = 15;
function startCustomerPraise(){
	spanPraise = document.getElementById("content");
	spanCustomer = document.getElementById("name");	
	praiseTimer = setInterval("paintPraise()", praiseSpeed);
}
function paintPraise(){
	if(typeof spanPraise!="undefined" && spanPraise!=null){
		if(currentPraiseColor >= 255){
			//time to switch testimonial
			currentPraiseIndex = (currentPraiseIndex + 1) % 5;
			spanPraise.innerHTML = praises[currentPraiseIndex][0];
			spanCustomer.innerHTML = "&#151; " + praises[currentPraiseIndex][1];
			praiseColorStep = -praiseColorStep;
		}
		var currentPraiseColorRGB = "rgb(" + currentPraiseColor + "," + currentPraiseColor + "," + currentPraiseColor + ")";
		spanPraise.style.color = currentPraiseColorRGB ;
		spanCustomer.style.color = currentPraiseColorRGB ;
		currentPraiseColor = (currentPraiseColor + praiseColorStep);
		if(currentPraiseColor <= 0){
			praiseColorStep = -praiseColorStep;
			currentPraiseColor = currentPraiseColor % 255;
		}
	}
}

$(document).ready(function(){startCustomerPraise();});
function country(){
	var url="/gifts/send-corporate-gifts-to-";
	var select = document.getElementById('xyz');
	var value=select.options[select.options.selectedIndex].value;
	document.location.href=url+value;
}
function livechat(wg){
	window.open("http://livechat.giftinginc.com/chat.php?intgroup=Q1MtR05J&hg=P0NTLVBVRg__&eh=aHR0cDovL2ltYWdlcy5naWZ0c25pZGVhcy5jb20vaW1hZ2VzL2Vjb21tZXJjZS9nbmktY2hhdC1oZWFkZXItaW1hZ2UuanBn","","width=510,height=610,left=0,top=0,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=yes");
	return false;
}

