
function paCreateRollOvers(){
	if(document.getElementById){
		var paImages = document.getElementsByTagName('IMG');
		var paButtons = document.getElementsByTagName('INPUT');
	}else if(document.all && navigator.userAgent.indexOf('Mac')==-1){
		var paImages = document.all['mouseovers'].all.tags('IMG');
		var paButtons = document.all['mouseovers'].all.tags('INPUT');
	}else return;
	paPreloads = new Object();

	for (var i = 0; i < paImages.length; i++){
		var paImageOffSrc = paImages[i].src + "";
		if(paImageOffSrc.indexOf("_off.") != -1){
			var paImageOnSrc = paImageOffSrc.replace(/_off\./g, "_on.");
			paPreloads['paImageOff_' + i] = new Image();
			paPreloads['paImageOff_' + i].src = paImageOffSrc;
			paPreloads['paImageOn_' + i] = new Image();
			paPreloads['paImageOn_' + i].src = paImageOnSrc;
			/*paPreloads['paImageOn_' + i].onerror = function(){this.src='/images/blank.gif';}*/
			paImages[i].onmouseover = function(){this.src = this.src.replace(/_off\./g, "_on.");}
			paImages[i].onmouseout = function(){this.src = this.src.replace(/_on\./g, "_off.");}
		}
	} 

	for (var i = 0; i < paButtons.length; i++){
		if(paButtons[i].src){
		var paImageOffSrc = paButtons[i].src + "";
		if(paImageOffSrc.indexOf("_off.") != -1){
			var paImageOnSrc = paImageOffSrc.replace(/_off\./g, "_on.");
			paPreloads['paImageOff_' + i] = new Image();
			paPreloads['paImageOff_' + i].src = paImageOffSrc;
			paPreloads['paImageOn_' + i] = new Image();
			paPreloads['paImageOn_' + i].src = paImageOnSrc;
			/*paPreloads['paImageOn_' + i].onerror = function(){this.src='/images/blank.gif';}*/
			paButtons[i].onmouseover = function(){this.src = this.src.replace(/_off\./g, "_on.");}
			paButtons[i].onmouseout = function(){this.src = this.src.replace(/_on\./g, "_off.");}
		}
		}
	} 
}

window.onload = paCreateRollOvers;

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function hide(id){ 
if (document.getElementById){ 
obj = document.getElementById(id); 
obj.style.display = "none"; 
} 
} 

function show(id){ 
if (document.getElementById){ 
obj = document.getElementById(id); 
obj.style.display = ""; 
} 
}

function showhide(id){ 
if (document.getElementById){
obj = document.getElementById(id); 
if (obj.style.display == "none"){ 
obj.style.display = ""; 
} else { 
obj.style.display = "none"; 
} 
} 
} 

myUrl = location.href;
mySub1 = ".php";
mySub2 = "-all.php";

function leftFromSubStringToBeginningOfFullString(fullString, subString) {
if (fullString.lastIndexOf(subString) == -1) {
return "";
} else {
return fullString.substring(0, fullString.lastIndexOf(subString));
}
}

function viewall() {
myText = leftFromSubStringToBeginningOfFullString(myUrl, mySub1);
document.write('<A HREF="');
document.write(myText); 
document.write('-all.php">');
document.write('View All');
document.write('</A>');
}

function normalview() {
myText = leftFromSubStringToBeginningOfFullString(myUrl, mySub2);
document.write('<A HREF="');
document.write(myText); 
document.write('.php">');
document.write('View Larger Photos');
document.write('</A>');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
   if (restore) selObj.selectedIndex=0;
   }

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}


function expandCollapse(objName) {
	obj = document.getElementById(objName + 'Content');
	objImg = document.getElementById(objName + 'Img');
	if(obj.style.display == "none") {
		obj.style.display = "block";
		objImg.src = objImg.src.replace(/_show\./g, "_hide.");
	}
	else {
		obj.style.display = "none";
		objImg.src = objImg.src.replace(/_hide\./g, "_show.");
	}
}



function MM_findObj(n, d) { //v4.0
  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&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

allrows=new Object();
allcols=new Object();
colsrows=new Object();
function get_itemsh_val(obj){
	if(obj.length && obj.length>0){
		for(i=0;i<obj.length;i++){
			if(obj[i].checked) return(obj[i].value);
		}
	}
	if(obj.options) return(obj.options[obj.options.selectedIndex].value);
	else return(obj.value);
}
function setopts(form_name, prefix, item_id, set_col, set_layers){
	f=document.forms[form_name];
//Set cols
	if(set_col && f['comb_col'+prefix].options){
		currrowval=-1;
		if(f['comb_col'+prefix].options) currcolval=f['comb_col'+prefix].options[f['comb_col'+prefix].options.selectedIndex].value;
//Clear options
		if(f['comb_col'+prefix].options) for(i=f['comb_col'+prefix].options.length;i>-1;i--) f['comb_col'+prefix].options[i]=null;
		newrowval=get_itemsh_val(f['comb_row'+prefix]);
		n=0;
		for(var i in colsrows[item_id][newrowval]){
			no = document.createElement("OPTION");
			no.text=allcols[item_id][i];
			no.value=i;
			if(i==currcolval) no.selected=1;
			f['comb_col'+prefix].options[n]=no;
			n++;
		}
	}
	newrowval=get_itemsh_val(f['comb_row'+prefix]);
	newcolval=get_itemsh_val(f['comb_col'+prefix]);
	comb_prod_id=colsrows[item_id][newrowval][newcolval]['comb_id'];
	if(set_layers){
//Set price
		MM_setTextOfLayer('pricelayer'+prefix,'',colsrows[item_id][newrowval][newcolval]['price_displ']);
		MM_setTextOfLayer('pricesalelayer'+prefix,'',colsrows[item_id][newrowval][newcolval]['price_sale_displ']);
		MM_setTextOfLayer('skulayer'+prefix,'',colsrows[item_id][newrowval][newcolval]['sku_displ']);
//Stock
		if(colsrows[item_id][newrowval][newcolval]['cstock']==1){
			displ_addtocart='block';
			displ_notify='none';
		}else{
			displ_addtocart='none';
			displ_notify='block';
		}
		obj=MM_findObj('addtocart');
		if(obj) obj.style.display=displ_addtocart;
		obj=MM_findObj('notify1');
		if(obj) obj.style.display=displ_notify;
	}
}