var ns6=document.getElementById&&!document.all;
var ie=document.all;
var ContainerID = "";
var processing = false;
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
var PanelArray = new Array("ShopStepPortrait","ShopStepPack","ShopStepDesign","ShopStepPackagingChoice");

var getOffsetHeight = 
    function(obj) {
	    return obj.offsetHeight;
};


function $get(id){
	if(ie)return document.all[id];
	else if(ns6) return document.getElementById(id);
}

function OnMouseOver(obj,srcurl){
	if(ie) obj.style.cursor="hand";
	else if(ns6) obj.style.cursor="pointer";

	if(srcurl != null)obj.src = srcurl;
}

function OnMouseOut(obj,srcurl){
	obj.src = srcurl;
}

function trim(str){
	s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}

function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
} 

function GetProcessBarDisplay(div){
	var myWidth = $get("DIVMain").offsetWidth,/*screen.width,*/ myHeight = $get("DIVMain").offsetHeight ;
	var oDiv = document.createElement("iframe");
	var oStyle = oDiv.style;
	var DivRef = $get(div);

	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;
	}

	oDiv.id="transDiv";
	oStyle.opacity = .5;
	oStyle.MozOpacity = .5;
	oStyle.KhtmlOpacity = .5;
	oStyle.filter = "alpha(opacity=50)";      
	oStyle.top = "0px";
	oStyle.left = "0px";
	oStyle.height = $get("DIVMain").offsetHeight + "px";
	oStyle.width = "100%";
	oStyle.position = "absolute";
	oStyle.backgroundColor = "#cccccc";
	oStyle.zIndex="4";
	document.body.appendChild(oDiv);

	//disableAll(document.body);

	//DivRef.style.display="block";
	DivRef.style.top = ((parseInt(myHeight) / 2) - 50) + "px";
	DivRef.style.left= ((parseInt(myWidth) / 2) - 50 ) + "px";
    DivRef.style.display = "block";
	//if (DivRef.style.display=="none") 
	//else DivRef.style.display = "none";
}

function GetProcessBarRemove(){
    try{
	    $get("ProcessBar").style.display="none";
	    var oDiv = $get("transDiv");
        if(oDiv != "undefined" || oDiv != null)document.body.removeChild(oDiv);
    }
    catch(e){}
}

function checkboxTick(obj){
	checkbox = $get(obj);
		
	if(checkbox.checked==false)checkbox.checked=true;
	else checkbox.checked=false;
}

function FindParentContainerID(objID){
    ContainerID = objID.substring(0,objID.lastIndexOf("_") + 1);
}

function setCursorAtEnd(objID) {
	var oTextbox = $get(objID);

	if(typeof oTextbox !="undefined" && typeof oTextbox != null){
		if (oTextbox.createTextRange) {
			var r = (oTextbox.createTextRange());
			r.moveStart('character', (oTextbox.value.length));        
			r.collapse();
			r.select();
		}
		else{
			oTextbox.value=oTextbox.value;
			oTextbox.focus();
		}
	}
}

function PopUpWindow(sUrl,width,height,target,position,toolbar,location){
	var LeftPosition = (screen.width)?Math.round((screen.width-width)/2):100;
	var TopPosition = (screen.height)?Math.round((screen.height-height)/2):100;
	var setting;
	if(position!="center")TopPosition = "500px";

	setting = "width=" + width + "px,height=" + height + "px,top=" + TopPosition + "px,left=";
	setting += LeftPosition + "px,scrollbars=yes,toolbar=" + toolbar + ",location=" + location 
	setting += ",directories=no,status=no,menubar=no,resizable=no,modal=yes'";

	window.open(sUrl,target,setting)
}

function checkmail(e){
	var returnval = emailfilter.test(e);
	return returnval;
}

function OnMouseOverHighlight(obj){
	obj.style.backgroundColor="#d0bbba";
	obj.style.textDecoration = "underline";
}

function OnMouseOutIdle(obj){
	obj.style.backgroundColor="#ffffff";
	obj.style.textDecoration = "none";
}


