function getHomeCatProds(sessionStr){

	if(sessionStr!=''){
		getFeaturedProducts(0,sessionStr);
		getFeaturedCategories(0,sessionStr);
	}else{
		getFeaturedProducts(0,'');
		getFeaturedCategories(0,'');
	}
	
	
}

function getFeaturedProducts(cat_id,sessionStr) {

		var frm_indx=document.getElementById('product_frm_indx').value;
		var pass_session;
		
		if(sessionStr!=''){
		 	pass_session="&"+sessionStr;
		}else{
			pass_session="";
		}
				
		var query =	"cat_id="+cat_id+"&frm_indx="+frm_indx+""+pass_session;
		var actionUrl='ajax_featured_products.php';
		
		$.ajax({
		type: "POST",
		url: actionUrl,
		data: query,
		cache: false,
		success: function(data){
				if($("#featured_products")) $("#featured_products").show();
				document.getElementById("featured_products").innerHTML = data;							 			 
		}
		});
				
}
 
function clickNextProduct(sessionStr){

	var frm_indx=document.getElementById('product_frm_indx').value;
	frm_indx=parseInt(frm_indx);	
	
	var total_products=document.getElementById('total_products').value;
	total_products=parseInt(total_products);
	
	
	var next_indx=frm_indx+4;
	next_indx=parseInt(next_indx);
	
	if(next_indx>=total_products){	
		next_indx=next_indx-total_products;	
	}
	
	document.getElementById("product_frm_indx").value = next_indx;
	
	if(sessionStr!=''){
		 	getFeaturedProducts(0,sessionStr);
	}else{
			getFeaturedProducts(0,'');
	}
	
	
}

function clickPreProduct(sessionStr){

	var total_products=document.getElementById('total_products').value;
	total_products=parseInt(total_products);

	var frm_indx=document.getElementById('product_frm_indx').value;
	frm_indx=parseInt(frm_indx)-4;
	
	if(frm_indx<0){
		frm_indx=total_products+frm_indx;
	}
	
	document.getElementById("product_frm_indx").value = frm_indx;
	if(sessionStr!=''){
		 	getFeaturedProducts(0,sessionStr);
	}else{
			getFeaturedProducts(0,'');
	}
}


function getFeaturedCategories(cat_id,sessionStr) {

		var frm_indx=document.getElementById('category_frm_indx').value;
		
		if(sessionStr!=''){
		 	pass_session="&"+sessionStr;
		}else{
			pass_session="";
		}
				
		var query =	"cat_id="+cat_id+"&frm_indx="+frm_indx+""+pass_session;
		var actionUrl='ajax_featured_categories.php';
				
		actionUrl = actionUrl;
		$.ajax({
		type: "POST",
		url: actionUrl,
		data: query,
		cache: false,
		success: function(data){								
				if($("#div_featured_categories")) $("#div_featured_categories").show();
				document.getElementById("div_featured_categories").innerHTML = data;							 			 
		}
		});
				
}
 
function clickNextCategory(sessionStr){

	var frm_indx=document.getElementById('category_frm_indx').value;
	frm_indx=parseInt(frm_indx);	
	
	var total_categories=document.getElementById('total_categories').value;
	total_categories=parseInt(total_categories);
	
	
	var next_indx=frm_indx+2;
	next_indx=parseInt(next_indx);
	
	if(next_indx>=total_categories){	
		next_indx=next_indx-total_categories;	
	}
	
	document.getElementById("category_frm_indx").value = next_indx;
	
	if(sessionStr!=''){
		 	getFeaturedCategories(0,sessionStr);
	}else{
			getFeaturedCategories(0,'');
	}
	
}

function clickPreCategory(sessionStr){

	var total_categories=document.getElementById('total_categories').value;
	total_categories=parseInt(total_categories);

	var frm_indx=document.getElementById('category_frm_indx').value;
	frm_indx=parseInt(frm_indx)-2;
	
	if(frm_indx<0){
		frm_indx=total_categories+frm_indx;
	}
	
	document.getElementById("category_frm_indx").value = frm_indx;
	if(sessionStr!=''){
		 	getFeaturedCategories(0,sessionStr);
	}else{
			getFeaturedCategories(0,'');
	}
}

function closeMyPopup() {
	document.getElementById("billboard_popup").style.display = "none";
}


function setOpacity( value ) {
	document.getElementById("billboard_popup").style.opacity = value / 10;
	document.getElementById("billboard_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ )
		setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
	for( var i = 0 ; i <= 100 ; i++ ) {
		setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
	}
	setTimeout('closeMyPopup()', 800 );
}



function fireMyPopup() {

setOpacity( 0 );
var obj=document.getElementById("billboard_popup");

obj.style.display = "block";
obj.style.top= "100px";
obj.style.left= "200px";;
obj.style.position= 'absolute';
	
fadeInMyPopup();
}


function getPositionLeft(This){
var el = This;var pL = 0;
while(el){pL+=el.offsetLeft;el=el.offsetParent;}
return pL
}

function getPositionTop(This){
var el = This;var pT = 0;
while(el){pT+=el.offsetTop;el=el.offsetParent;}
return pT
}



function openPopupImage(sPicURL) {
	window.open( "billboard_popup_image.php?"+sPicURL, "",  
"resizable=1,HEIGHT=200,WIDTH=200,scrollbars=yes,location=no,menubar=no,status=no,toolbar=no,dialog=yes");	
}

function openPopupWin(siteURL) {
	window.open(''+siteURL, "",  
"resizable=1,HEIGHT=400,WIDTH=400,scrollbars=yes,location=no,menubar=no,status=no,toolbar=no");	
}



