var href = location.href.split('/');
var https = href[0];
var domain = href[2];
function inputBox(pid,spanId)
{
	var text = '<input type="text" size="1" name="product['+pid+']" value=1>';
	document.getElementById(spanId+pid).innerHTML = text;
}
function modifyQty(pid, inputId, op)
{
	var value = document.getElementById(inputId).value;
	if (op == 'add') {
		document.getElementById(inputId).value = Number(value) + 1;
	}
	else {
		if (value > 0) {
			document.getElementById(inputId).value = Number(value) - 1;
		}
	}
}
function sendCookie(formName, inputId)
{
//	var frms = document.forms;
//	var len = frms.length;
//	for (var k=0; k<len; k++) {
//		alert(frms[k].elements[0].id);
//
//	}

	var cookieBits = document.cookie.split(';');
	var cnt = cookieBits.length;
	for (var i=0; i<cnt; i++) {
		var crumbs = cookieBits[i].split('=');
		if (crumbs[0] == ' PHPSESSID') {
			document.getElementById(inputId).value=crumbs[1];
			document.forms[formName].submit();
		}
	}

}
window.addEvent('domready',function(){
	if($('recentlyViewed') && location.href!='http://apothica.com/')
	{
		new pScroll({
			parentDiv : 'recentlyViewed',
			orientation:'vertical',
			url:https+'//'+domain+'/p_include/ajax_func.html',
			viewAllLink:'recentlyViewed.html',
			title:'Recently Viewed',
			productHeight:150
		});
	}
	if($('recentlyViewed2'))
	{
		new pScroll({
			parentDiv : 'recentlyViewed2',
			orientation:'horizontal',
			url:https+'//'+domain+'/p_include/ajax_func.html',
			title:'Recently Viewed',
			viewAllLink:'recentlyViewed.html'
		});
	}
	if($('alsoViewed'))
	{
		new pScroll({
			parentDiv : 'alsoViewed',
			orientation:'horizontal',
			url:https+'//'+domain+'/p_include/ajax_func.html',
			title:'Other Customers Also Viewed',
			viewAllLink:'alsoViewed.html?pid='+$('alsoViewed').lang,
			func:'getAlsoViewed&product_id='+$('alsoViewed').lang
		});
	}
	if($('alsoPurchased'))
	{
		new pScroll({
			parentDiv : 'alsoPurchased',
			orientation:'horizontal',
			url:https+'//'+domain+'/p_include/ajax_func.html',
			title:'Other Customers Also Purchased',
			viewAllLink:'alsoPurchased.html?pid='+$('alsoPurchased').lang,
			func:'getAlsoPurchased&product_id='+$('alsoPurchased').lang
		});
	}

	if($('mediaBuzz'))
	{
		new mScroll({
			parentDiv : 'mediaBuzz',
			orientation:'horizontal',
			url:https+'/p_include/ajax_func.html',
			title:'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
			numberOfProducts: 3,
			viewAllLink:'mediaBuzz.html',
			productHeight: 80,
			productWidth: 130,
			func:'getMediaBuzzForProductView&productId='+$('mediaBuzz').lang
		});
	}

	if($('manufacturerMediaBuzz'))
	{
		new mScroll({
			parentDiv : 'manufacturerMediaBuzz',
			orientation:'horizontal',
			url:https+'/p_include/ajax_func.html',
			viewAllLink:'mediaBuzz.html',
			//title:'',
			func:'getMediaBuzzForManufacturerView&manufacturerTemplateId='+$('manufacturerMediaBuzz').lang
		});
	}
});

window.onbeforeunload = function(){
	new Request({
		'url':https+'//'+domain+'/p_include/ajax_func.html',
		'method':'post',
		'async':false,
		onComplete:function(response){
//			alert(response);
		}
	}).send('func=updatePageUnload')
}