function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,ia=MM_preloadImages.arguments; for(i=0; ia.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function preloadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

//window.onload = preloadImages("gfx/ragbag_logo.gif","gfx/spacer.gif","gfx/delhi_off.gif","gfx/delhi_on.gif","gfx/collection_off.gif","gfx/collection_on.gif","gfx/colours_off.gif","gfx/colours_on.gif","gfx/shoplocator_off.gif","gfx/shoplocator_on.gif","gfx/contact_off.gif","gfx/contact_on.gif","gfx/back.gif", "gfx/newdelhi.gif","gfx/bags_off.gif","gfx/bags_on.gif","gfx/folders_off.gif","gfx/folders_on.gif","gfx/organizer_off.gif","gfx/organizer_on.gif","gfx/wallet_off.gif","gfx/wallet_on.gif","gfx/shoppers_off.gif","gfx/shoppers_on.gif","gfx/kleur_pakistan.gif","gfx/kleur_strawberry.gif","gfx/kleur_icecube.gif","gfx/kleur_mango.gif","gfx/kleur_india.gif","gfx/kleur_indianocean.gif","gfx/kleur_pakistan_on.gif","gfx/kleur_strawberry_on.gif","gfx/kleur_icecube_on.gif","gfx/kleur_mango_on.gif","gfx/kleur_india_on.gif","gfx/kleur_indianocean_on.gif","gfx/rond_grijs.gif","gfx/rond_pakistan.jpgs","gfx/rond_strawberry.jpg","gfx/rond_icecubejpg","gfx/rond_mango.jpg","gfx/rond_india.jpg","gfx/rond_indianocean.jpg","gfx/ragbag_logo_home.gif","gfx/back.gif","gfx/collection_page/ka_chung_opzij.jpg","gfx/collection_page/ka_chung_staat.jpg","gfx/collection_page/ka_chung_zit.jpg","gfx/collection_page/ka_chung_loopt.jpg","gfx/collection_page/01.jpg","gfx/collection_page/02.jpg","gfx/collection_page/03.jpg","gfx/collection_page/04.jpg","gfx/collection_page/05.jpg","gfx/collection_page/06.jpg","gfx/collection_page/07.jpg","gfx/collection_page/08.jpg","gfx/collection_page/09.jpg","gfx/collection_page/10.jpg","gfx/collection_page/11.jpg","gfx/collection_page/12.jpg","gfx/collection_page/13.jpg","gfx/collection_page/14.jpg","gfx/collection_page/15.jpg","gfx/collection_page/16.jpg","gfx/collection_page/17.jpg","gfx/collection_page/18.jpg","gfx/collection_page/19.jpg","gfx/collection_page/20.jpg","gfx/collection_page/21.jpg","gfx/collection_page/22.jpg","gfx/collection_page/23.jpg","gfx/collection_page/24.jpg","gfx/collection_page/25.jpg");


function BrowserCheck(){
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4plus = (document.all) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
	ver4 = (NS4 || IE4plus) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
	IE5plus = IE5 || IE6;
	IEMajor = 0;
	Mozilla = navigator.userAgent.indexOf('Mozilla')!=-1?true:false;

	if (IE4plus){
		var start = navigator.appVersion.indexOf("MSIE");
		var end = navigator.appVersion.indexOf(".",start);
		IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
		IE5plus = (IEMajor>=5) ? true : false;
	}
	
	// Mac = 0 
	// Netscape = 1
	// IE = 2
	if (isMac || IEmac) ret = 0;
	if (NS4 || NS6 || Mozilla) ret = 1;
	if (IE4 || IE5 || IE6 || IE4plus || IE5plus) ret = 2;

	return ret;
}



function FCTback(clear){
	document.shop.action = "shop.php";
	document.shop.clear.value = clear;
	document.shop.submit();
}

function backTo(from){
	window.location = from;
}

function LTrim(str) {
	if (str.length == 0) {return str};
	intSpaceFound = str.indexOf(" ");
	while (intSpaceFound == 0 ) {
		str = str.substring(1,str.length);
		intSpaceFound = str.indexOf(" ");
	}	
	return str;
}

function RTrim(str) {
	if (str.length == 0) {return str};
	intSpaceFound = str.lastIndexOf(" ");
	while (intSpaceFound > 0 && intSpaceFound == str.length - 1) {
		str = str.substring(0,str.length - 1);
		intSpaceFound = str.lastIndexOf(" ");
	}	
	return str;
}

function Trim(str) {
	str = LTrim(str);
	str = RTrim(str);
	return str;
}


function submitForm(jump, action){
	document.forms[0].jumpto.value = jump;
	document.forms[0].action = action;
	document.forms[0].submit();
}


function checkFormShop(errorMsg){
	if (Trim(document.forms[0]["qty"].value) == "" || document.forms[0]["qty"].value == "0" || isNaN(document.forms[0]["qty"].value)) {
			alert(errorMsg);
			document.forms[0]["qty"].focus();
			return false;
	}
	document.forms[0].qty.value = parseInt(document.forms[0].qty.value);
	document.forms[0].submit();
	return true;	
}


function delfrom(itemid){
	document.forms[0].delitemid.value = itemid;
	document.forms[0].action = "cash.php";
	document.forms[0].submit();
}


// =======================================
// S L I D E S H O W
// =======================================

// Set speed (milliseconds)
var speed = 1400
var t
var j = 0
function runSlideShow(){
   document.images.SlideShow.src = preLoad[j].src;
   j = j + 1;
   if (j > (p-1)) j=0;
   t = setTimeout('runSlideShow()', speed);
}


function checkFormLogin(frm, mode, emailadres, m1, m2){

	var melding = "";
	document.forms[frm].log.value = mode;

	//--- Email
	if (Trim(document.forms[frm].email.value) == emailadres){
			veld	= "email";
			melding	= m1;
	}

	if (mode == 0){
			//--- Password
			if (Trim(document.forms[frm].wachtwoord.value) == "xxxxxxx"){
				veld	= "wachtwoord";
				melding	= m2;
			}
	}

	if (Trim(melding) != ""){
			alert(melding);
			document.forms[frm][veld].focus();
			return false;
	}

	return true;
}
