function start(){
	
}
function reloadPostages() {
	document.frontForm._eventId.value='reloadPostage';
	document.forms['frontForm'].submit();
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function addBookmark(title,url) {
	if (window.sidebar) {
  		window.sidebar.addPanel(title, url,"");
 	} else if( document.all ) {
 		window.external.AddFavorite( url, title);
 	} else if( window.opera && window.print ) {
 		return true;
	}
}

function printPopup() {
	var printUrl=document.location.href;
	if (printUrl.indexOf('#') > 0) printUrl = printUrl.substring(0,printUrl.indexOf('#'));
	if (printUrl.indexOf('?') > 0) printpop(printUrl + "&print=1");
	else printpop(printUrl + "?print=1");
}

function notifyFriend(params){
	var sLocation = document.location.href;
	if( sLocation.indexOf("?") == -1 ) sLocation ;
	else sLocation;
	if (params==null) params="";
	var s = "/notify_friend_window.xml";
	s += "?document_href=" + escape( sLocation );
	s += "&amp;" + params;
	window.open(s, 'notify_friend', 'width=458,height=382,menubar=no,resizable=no,left=' + ((window.screen.width - 320)/2 ) + ',top=' + ((window.screen.height - 300)/2 )).focus();  
}

function printpop(url) {
	var Win;
	if(window.screen)
	{
		aw = screen.availWidth;
		ah = screen.availHeight;
	}
	else{
		aw=640;
		ah=480;
	}
	Win=window.open(url,'print',"width=600, height=600,left=" +(aw-590)/2+",top=" +(ah-600)/2 + ",toolbar=no,location=no,directories=no," +"status=no,menubar=no," +"scrollbars=yes,resizable=no");

}

function openNewWindow(url, x, y, scrollbars, resizable)
{
 	 aPopUp = window.open('','VALLIST');	
 	 aPopUp.close();
 	 var left = (screen.availWidth/2) - (x/2);
	 var top = (screen.availHeight/2) - (y/2);
 	
    aPopUp= self.window.open(url,'VALLIST','toolbar=no,location=no,directories=no,status=yes,scrollbars='+scrollbars+',resizable='+resizable+', copyhistory=no,width='+x+',height='+y+',top='+top+',left='+left);
    self.aNoteWin = aPopUp;
}
			
function addToCard(variantId,variantTitle) {

	if (!document.getElementById('basket-small')) {
	
		document.location.href = '/add-to-cart.bhtml?variant_id='+variantId;
		return false;
	}
	
	$.ajax({
		url:'/add-and-refresh-cart.bhtml', 
		type:'POST', 
		data: {pVariantId: variantId},
		success: function(html){
			$('#basket-small').html(html);      				
			showNotify(variantTitle, '');      				
		},
		error: function() {}
	});
	return false;
}

function showSingleVariant(el) {
	value = el.value.split(',',2);
	val = value[0];
	cont = document.getElementById("av_avail");
	variants = cont.getElementsByTagName("DIV");
	
	var addToCartEscape=jQuery('#addToCartEscape');
	var addToCartEscapeH=jQuery('#addToCartEscapeH');
	for (i=0; i<variants.length; i++) { 
		variants[i].style.diWsplay = "none";
		if (variants[i].id == "av_"+val){
			variants[i].style.display = "block"; 
			if(variants[i].getAttribute('rel')=='true'){
				addToCartEscape.hide();
				addToCartEscapeH.show();
				if(jQuery('#av_'+val+' .notOrderable').length){
					jQuery("#notOrderable").html(jQuery('#av_'+val+' .notOrderable').html());
				}
			}
			else { 
				addToCartEscapeH.hide();
				addToCartEscape.show();
				jQuery("#notOrderable").html('');
			}
		}
	}
}

function showVariant(el) {
	value = el.options[el.selectedIndex].value.split(',',2);
	val = value[0];
	cont = document.getElementById("av_avail");
	variants = cont.getElementsByTagName("DIV");
	
	var addToCartEscape=jQuery('#addToCartEscape');
	var addToCartEscapeH=jQuery('#addToCartEscapeH');
	if(val=='0'){
		$('#av_avail, #notOrderable').hide();
		addToCartEscape.hide();
		addToCartEscapeH.hide();
	}else{
		$('#av_avail, #notOrderable').show()
	}
	for (i=0; i<variants.length; i++) { 
		variants[i].style.display = "none";
		if (variants[i].id == "av_"+val){
			variants[i].style.display = "block"; 
			if(variants[i].getAttribute('rel')=='true'){
				addToCartEscape.hide();
				addToCartEscapeH.show();
				if(jQuery('#av_'+val+' .notOrderable').length){
					jQuery("#notOrderable").html(jQuery('#av_'+val+' .notOrderable').html());
				}
			}
			else { 
				addToCartEscapeH.hide();
				addToCartEscape.show();
				jQuery("#notOrderable").html('');
			}
		}
	}
}
function appendOnloadEvent(eventHandler) {
	  if (window.onload) {
		window.onload = new Function(
		  window.onload.toString().replace(/[\r\n]/g, '').replace(/\s+$|^\s+/g, '').replace(
			/^function\s*\w+\s*\(\w*\)\s*\{\s*(.*)\s*\}$/,'$1\n' + eventHandler )
		);
	  } else {			
		window.onload = new Function(eventHandler);
	  } 		
}
	
function hideNotify() {
	node = document.getElementById('alertLayer')
	if (node) {
		document.getElementById("top").removeChild(node);
	}
}	
	
function showNotify(prodTitle, msg) {

	height = (navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + (innerHeight/2) - 100 : (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop) + ((window.screen.height-200)/2) - 100;

	hideNotify();	
	notifyLayer = document.createElement('div')
	notifyLayer.id = "alertLayer";
	notifyLayer.onclick = function () {hideNotify();};
	notifyLayer.style.height =((navigator.appName.indexOf("Netscape") != -1) ? pageYOffset + innerHeight: (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop) + window.screen.height-200) +'px';

	notify = document.createElement('div')
	notify.id = "addToCartAlert";

	ifr = document.createElement('iframe');
	ifr.id = "alertIfr";
	ifr.frameBorder = "0";
	ifr.style.marginTop = height+'px';
	ifr.setAttribute('allowtransparency',true);

	pClose = document.createElement('img');
	pClose.src="/images/www/spacer.gif"
	pClose.id = "closeAlert";
	pClose.onclick = function() {hideNotify();};
	
	pIntro = document.createElement('p');
	pIntroText = document.createTextNode('Added to your basket:');
	pIntro.appendChild(pIntroText);

	pContener = document.createElement('div');
	pContener.id="alertContener";
	
	pProd = document.createElement('h2');
	pProd.id = "alertProdTitle"
	pProd.innerHTML = prodTitle;

	pInputCont = document.createElement('span');
	pInputCont.className = 'more';
	pInputCont.onclick=function() {hideNotify();};
	pInputText = document.createTextNode('Continue shopping');
	pInputCont.appendChild(pInputText);
	
	pCartLink = document.createElement('a');
	pCartLink.className = 'more more_red';
	pCartLink.href = '/cart.bhtml';
	pCartText = document.createTextNode('Go to Checkout');
	pCartLink.appendChild(pCartText);
	
	notify.appendChild(pClose);
	notify.appendChild(pIntro);
// notify.appendChild(pProd);
	pContener.appendChild(pProd);
	for(var j=0; j < msg.length; j++) {
		pService = document.createElement('h2');
		pService.id = "alertProdTitle"
		pServiceText = document.createTextNode(msg[j]);
		pService.appendChild(pServiceText);
		pContener.appendChild(pService);
	}	
	notify.appendChild(pContener);
	notify.appendChild(pInputCont);
	notify.appendChild(pCartLink);
	notifyLayer.appendChild(ifr);
	notifyLayer.appendChild(notify);
	

	document.getElementById("top").appendChild(notifyLayer);	
	document.getElementById("container").onclick = function() {hideNotify();};
}	
			
function showPhoto(midi, maxi, el) {
	$('#medium-photo-A img').attr('src',midi);
	$('#medium-photo-A').attr('href',maxi);
	$('.photoactive').removeClass('photoactive')
	/*
	ml = document.getElementById('medium-link');
	ml.onclick=function() { return winGalleryOpen('/photo/'+maxi);};

	mp = document.getElementById('medium-photo');
	mp.src='/photo/'+midi;
	mp.onclick=function() {winGalleryOpen('/photo/'+maxi);};

	thumbs = document.getElementById('add-photos').childNodes;
	 */
	for (i=0; i<thumbs.length; i++) {
		if(thumbs[i]==el) thumbs[i].className='photoswitch  photoactive';
		else thumbs[i].className='photoswitch';
	}
	return false;
}
			
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function eraseCookie(name){
	createCookie(name,"",-1);
}			
	
function trimFieldProductNumber(form) {
	var str = form.productNumber.value;
	while (str.substring(0,1) == ' ')
		str = str.substring(1, str.length);
	while (str.substring(str.length-1, str.length) == ' ')
		str = str.substring(0,str.length-1);
	form.productNumber.value=str;
}

function checkProductNumber(form) {
	trimFieldProductNumber(form);
	if (!form.productNumber.value || form.productNumber.value.length==0) { alert('Please input product number'); return false; }
	return true;
}	
	
function trimField(form) {
	var str = form.keyword.value;
	while (str.substring(0,1) == ' ')
		str = str.substring(1, str.length);
	while (str.substring(str.length-1, str.length) == ' ')
		str = str.substring(0,str.length-1);
	form.keyword.value=str;
}

function checkWord(form) {
	trimField(form);
	return true;
}		
			

	
	/*
	 * function addToCardWithServices(prodId,prodTitle, services, msg) {
	 * 
	 * if (!document.getElementById('basket-small')) { document.location.href =
	 * '/add-to-cart.bhtml?prod_id='+prodId; return false; }
	 * 
	 * $.ajax({ url:'/add-and-refresh-cart.bhtml', type:'POST', data:
	 * {productId: prodId, serviceItem: services}, success: function(html){
	 * $('#basket-small').html(html); showNotify(prodTitle, msg); }, error:
	 * function() { } });
	 * 
	 * return false; }
	 * 
	 * 
	 * function winPromoOpen(url) { var Win; if (Win) Win.close(); Win =
	 * window.open("/js/promo-view.html?"+url,"photo","width=800, height=600,
	 * scrollbars=yes,resizable=yes,menubar=no,status=no"); }
	 * 
	 * 
	 */