 /*
			All SHOP RELATED SCRIPTS FOR GENERAL USE
			JORR-CMS
			BY J-Duin  (ditnet.nl)
*/

	// BROWSER DETECTIE
	var agent = navigator.userAgent.toLowerCase();
	var isMac = agent.indexOf("mac") != -1;
	var isWindows = agent.indexOf("win") != -1;
	var isUnix = agent.indexOf("X11") != -1;
	var isIe = navigator.appName.indexOf("Microsoft") != -1;
	var isNetscape = navigator.appName.indexOf("Netscape") != -1;
	var browserVersion = parseInt(navigator.appVersion);

var win;	
var preloadflag=false;

/*
	Get the selected value from a selectbox object (e)
	*/
	function getSelectValue(e){
		var value;
		for(var i = 0; i < e.options.length ; i++){
			if(e.options[i].selected){
				value = e.options[i].value;
			}
		}
		return value;
	}
	/*
	Set the selected value from a selectbox object (e) where value == str
	*/
	function setSelectValue(e,str){
		for(var i = 0; i < e.options.length ; i++){
			if(e.options[i].value==str){
				e.options[i].selected=true;
			}
		}
	}




	function openWindow(url,width,height){
		// open a window 
		win = window.open(url,"Sitewindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+width+",height="+height);
		return false;
	}
	
	function changeImages(){
	/*
	Swap image
	index 0 = name
	index 1 = src
	*/
	str = 'document.images.'+changeImages.arguments[0]+'.src = \''+ changeImages.arguments[1]+'\'';
	if(preloadflag){eval(str);}
	}
	
	
	function uitprinten(){
	
		
		
		this.window.focus();
		window.print();
		
		
	
	}


/* Called from main window in productsummaryrow.htm 
*/
function AddItem(o){
	d = new Date();
	t = escape(d.getTime());
	openWindow('basket.php?t='+t+'&language=nl&i='+o.name,470,600)
	return false;
}

function naarKassa(s,lang){
	d = new Date();
	t = escape(d.getTime());
	self.document.location = s+'?pageid=kassa&language='+lang+'&t='+t;
	
};


function delProd(e){
			
			
			
			var ar = e.name.split("_");
			if(!ar.length==4){return false;}
			if(isNaN(ar[0])){return false;}
			var pid = ar[0];
			var bid = ar[1];
			var lid = ar[2];
			var aid = ar[3];
			var t = new Date();
			var win = window.open('','','width=10, height=10');
			// var win = window.open();
			win.document.open();
			win.document.write('<html><head> <title>------</title></head><body bgcolor="#000000">');
			win.document.write('<form>');
			win.document.write('....');
			win.document.write('<input type="hidden" name="pid" value=""/>');
			win.document.write('<input type="hidden" name="bid" value=""/>');
			win.document.write('<input type="hidden" name="lid" value=""/>');
			win.document.write('<input type="hidden" name="aid" value=""/>');
			win.document.write('<input type="hidden" name="mode" value=""/>');
			win.document.write('</form>');
			win.document.write('</body></html>');
			win.document.close();	
			win.document.forms[0].method="post";
			win.document.forms[0].pid.value=pid;
			win.document.forms[0].bid.value=bid
			win.document.forms[0].lid.value=lid;
			win.document.forms[0].aid.value=aid;
			win.document.forms[0].mode.value='del';
			win.document.forms[0].action="basket.php?t"+t.getTime()+"&language=nl";
			win.document.forms[0].submit();
			
				
			
		}

function Check_is_str_email(str){
	ctrue=0;// 
	tempar=str.split('@');// check for @
	if(tempar.length==2){ctrue++;}
	tempar=str.split('.');// check for .
	if(tempar.length>1){ctrue++;}
	if(ctrue==2){return true;}else{return false;}	
}

	

// ------------------------------------------------------------------------------------
/* ******************************************************

By Naresh Hotchandani, nhotchandani@rediffmail.com
Modified by Ryan Parman
****************************************************** */
function message(text)
{
	this.text=(text) ? text:null;

	this.calcKey=function(ckey)
	{
		len=0;
		ckeylen=ckey.length;
		for(i=0; i<ckeylen; i++) len+=ckey.charCodeAt(i);
		return parseInt(len);
	}

	this.encrypt=function(key)
	{
		net="";
		fin=0;
		len=this.calcKey(key.toString());
		if(len>0)
		{
			etxtlen=text.length;
			if(etxtlen>0)
			{
				for(i=0; i<etxtlen; i++)
				{
					fin=text.charCodeAt(i)+len;

					if(fin>99) net+=fin;
					else net+='0'+fin;
				}
			}
		}
		return net;
	}

	this.decrypt=function(key)
	{
		var j=3;
		var temp1;
		var res="";
		len=this.calcKey(key.toString());
		if(len>0)
		{
			dtxtlen=text.length;
			if(dtxtlen>0)
			{
				for(i=0; i<dtxtlen; i+=3)
				{
					var temp=text.substring(i,j);
					temp1=(parseInt(temp)-len);
					var t=unescape('%'+temp1.toString(16));

					if(t=='%d' || t=='%a') res=res+' ';
					else res=res+t;
					j+=3;
				}
			}
		}
		return res;
	}
}
