// JavaScript Document
divX = 0
divY = 0
function findShimmyPosition(){   
    var c = getAnchorPosition('shimmy');
	divX = c.x;
    divY = c.y;
}

function hidethis(){
    Obj = getElmByIdq("divtrans");
    var Obj2 = getElmByIdq("overlay");
    Obj.style.visibility="hidden";
    Obj2.style.visibility="hidden";
    Obj.style.width="100%"
	for(xy=1;xy<=(arrIDS.length-1); xy = xy + 1){
		document.getElementById('sl'+arrIDS[xy]).style.visibility='visible';
	}
}

function getElmByIdq(aID)    { 
        var element = null; 
        element = document.getElementById(aID) 
		//alert("aID");
        return element; 
    }    
    
function moreproductinfo(ct,id)
{
	for(xy=1;xy<=(arrIDS.length-1); xy = xy + 1)
	{
		document.getElementById('sl'+arrIDS[xy]).style.visibility='hidden';
	}
 
	//document.getElementById('thebody').style.overflow='hidden'; 
    	//findShimmyPosition()
    Obj = getElmByIdq("divtrans");
    var Obj2 = getElmByIdq("overlay");
    
	    //var divonly = getElmByIdq("div_cell_only");     
	    //alert(Obj.style.visibility);
	    //Obj.style.left = divX;
	    //Obj.style.top = divY;
	    //getMyXY(Obj);
	    //getMyXY(divonly);
    Obj.style.visibility="visible";
    Obj2.style.visibility="visible";
    
    obj1 = getElmByIdq("spanTypeName")
    obj2 = getElmByIdq("spanPic")
    obj3 = getElmByIdq("spanPricing")
    obj4 = getElmByIdq("spanTypeDesc")
    obj5 = getElmByIdq("spanBuyLink")
    obj6 = getElmByIdq("spanQty")
	obj7 = getElmByIdq("spancopperwarning")
    
    obj1.innerHTML = arrHeaders[ct];
    obj2.innerHTML = "<img src='" + arrPic[ct] + "'  />";
	//obj3.innerHTML = arMPrice[ct][1] ;
	arrPriceStr = arMPrice[ct][1];
	
	//bug: come back and fix!!!
    
    arrPriceStr = arrPriceStr.replace(/\:/g,"<br>");
    	    
	
    obj3.innerHTML = arrPriceStr;
		//arrQtyStr = arQty[ct];
		// obj3.innerHTML = arrQtyStr.replace(/\;/g,"<br>");
		//alert(arrPriceStr);
		//obj3.innerHTML = arPrice[id];
	obj4.innerHTML = arrContent[ct];
		// obj6.innerHTML = arQty[ct];
   	var arrQtyStr = arQty[ct];
	arrQty = arrQtyStr.split(";");
	if((arrQty.length-1) == 0){		
		obj6.innerHTML = "<select class='slqty' onchange='doreloadprices(\""+ct+"\",\""+id+"\")' id='sl"+id+"-2' name='sl"+id+"-2'><option value='0'> - Qty - </option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select>";
	}else{
		for(xx=0;xx<=(arrQty.length-1); xx = xx + 1){	
			if(xx == 0){
				arrQtyStr = arrQtyStr + "<option value='" + arrQty[xx] + "' selected>" + arrQty[xx] + "</option>";
			}else{
				arrQtyStr = arrQtyStr + "<option value='" + arrQty[xx] + "'>" + arrQty[xx] + "</option>";
			}
		}
		//arrQtyStr = arrQty.length;
		//obj6.innerHTML = "<select class='slqty'><option value='0'>"+arrQtyStr+"</option></select>";
		obj6.innerHTML = "<select class='slqty' onchange='doreloadprices(\""+ct+"\",\""+id+"\")'  id='sl"+id+"-2' name='sl"+id+"-2'><option value='0'> - Qty - </option>"+arrQtyStr+"</select>";
	}
	//alert(arPrice[ct]);
    
    obj5.innerHTML = "<img src='../images/template/add_to_cart.gif' border='0' style='cursor:pointer' onclick='AddToCart(\""+ct+"\",\""+id+"\",\""+arMPrice[ct][1]+"\",\"large\",\""+arrHeaders[ct]+"\",\"-2\");window.location=\"buynow.php\"'>";
	
	if(arrHeaders[ct] == "MyCopper"){
		obj7.innerHTML = "Only available in South Africa.";		
		}else{
		obj7.innerHTML = "";	
		}
	
	

}

function moreproductinfoPage(ct,id)
{
	
 
 
    var Obj2 = getElmByIdq("overlay");
    


    obj1 = getElmByIdq("spanTypeName")
    obj2 = getElmByIdq("spanPic")
    obj3 = getElmByIdq("spanPricing")
    obj4 = getElmByIdq("spanTypeDesc")
    obj5 = getElmByIdq("spanBuyLink")
    obj6 = getElmByIdq("spanQty")
	obj7 = getElmByIdq("spancopperwarning")
    
    obj1.innerHTML = arrHeaders[ct];
    obj2.innerHTML = "<img src='" + arrPic[ct] + "'  />";

	arrPriceStr = arMPrice[ct][1];
	

    
    arrPriceStr = arrPriceStr.replace(/\:/g,"<br>");
    	    
	
    obj3.innerHTML = arrPriceStr;
	
	obj4.innerHTML = arrContent[ct];
	
   	var arrQtyStr = arQty[ct];
	arrQty = arrQtyStr.split(";");
	if((arrQty.length-1) == 0)
	{
		obj6.innerHTML = "<select class='slqty' onchange='doreloadprices(\""+ct+"\",\""+id+"\")' id='sl"+id+"-2' name='sl"+id+"-2'><option value='0'> - Qty - </option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select>";
	}
	else
	{
		for(xx=0;xx<=(arrQty.length-1); xx = xx + 1)
		{	
			if(xx == 0)
			{
				arrQtyStr = arrQtyStr + "<option value='" + arrQty[xx] + "' selected>" + arrQty[xx] + "</option>";
			}
			else
			{
				arrQtyStr = arrQtyStr + "<option value='" + arrQty[xx] + "'>" + arrQty[xx] + "</option>";
			}
		}
		
		obj6.innerHTML = "<select class='slqty' onchange='doreloadprices(\""+ct+"\",\""+id+"\")'  id='sl"+id+"-2' name='sl"+id+"-2'><option value='0'> - Qty - </option>"+arrQtyStr+"</select>";
	}
	
    
    	obj5.innerHTML = "<img src='../images/template/add_to_cart.gif' border='0' style='cursor:pointer' onclick='AddToCart(\""+ct+"\",\""+id+"\",\""+arMPrice[ct][1]+"\",\"large\",\""+arrHeaders[ct]+"\",\"-2\");window.location=\"buynow.php\"'>";
	
	if(arrHeaders[ct] == "MyCopper")
	{
		obj7.innerHTML = "Only available in South Africa.";
	}
	else
	{
		obj7.innerHTML = "";	
	}

}

function getMyXY(o)
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) //Non-IE
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) //IE 6+ in 'standards compliant mode'
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) //IE 4 compatible
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	else
	{
		myHeight = document.getElementById('mesure').offsetHeight;
		myWidth = document.getElementById('mesure').offsetWidth;
	}

	var w = o.offsetWidth;
	var h = o.offsetHeight;

	var x = Math.round((myWidth/2)-(w/2));
	var y = Math.round((myHeight/2)-(h/2));
	y += document.body.scrollTop;

	o.style.left = x+'px';
	o.style.top = y+'px';
}


function moreinfo(picname){
	//document.getElementById('thebody').style.overflow='hidden'; 
    var Objdivoverlay = getElmByIdq("overlay");
    Obj = getElmByIdq("divtrans")
	//alert(Obj.style.visibility);
    Obj.style.left = divX;
    Obj.style.top = divY;
    getMyXY(Obj);
    Obj.style.visibility="visible";
    Objdivoverlay.style.visibility="visible";
    obj2 = getElmByIdq("spanPic")    
    obj2.innerHTML = "<img src='../UploadsImages/" + picname + "' style='border:1px solid #000000' />";
}
function moreinfobackend(picname){
	//document.getElementById('thebody').style.overflow='hidden'; 
    var Objdivoverlay = getElmByIdq("overlay");
    Obj = getElmByIdq("divtrans")
	
    Obj.style.left = divX;
    Obj.style.top = divY;
    getMyXY(Obj);
    Obj.style.visibility="visible";
    Objdivoverlay.style.visibility="visible";
    obj2 = getElmByIdq("spanPic")    
    obj2.innerHTML = "<img src='../" + picname + "' style='border:1px solid #000000' />";
}
function moreflashinfo(linkname)
{
	//document.getElementById('thebody').style.overflow='hidden'; 
	var Objdivoverlay = getElmByIdq("overlay");
	Obj = getElmByIdq("divtrans")
	
	Obj.style.left = divX;
	Obj.style.top = divY;
	getMyXY(Obj);
	Obj.style.visibility="visible"
	Objdivoverlay.style.visibility="visible";
	obj2 = getElmByIdq("spanPic")    
	obj2.innerHTML = "<object width=\"425\" height=\"344\"><param name=\"movie\" value=\"" + linkname + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + linkname + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>"
	
}