<!--

var BROWSER_IE4 = "IE4"
var BROWSER_NN4 = "NN4"
var BROWSER_IE = "IE"
var BROWSER_VER;
BROWSER_VER = checkBrowser()


/*
if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}
*/
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page


function checkBrowser() {
var BROWSER_VER;
  if (document.all && !document.getElementById) 
	BROWSER_VER = BROWSER_IE4
  else if (document.layers) 
	BROWSER_VER = BROWSER_NN4
  else if (document.getElementById) 
	BROWSER_VER = BROWSER_IE
  else 
	BROWSER_VER = BROWSER_IE
   return(BROWSER_VER)
}


function showBubbleTable(tableToShow,position){

holder = eval("document.all")
holder[tableToShow].style.top = getTop(position)+5;
holder[tableToShow].style.left = getLeft(position);
if (holder[tableToShow].style.visibility == 'visible') {
holder[tableToShow].style.visibility = 'hidden';
}
else{
holder[tableToShow].style.visibility = 'visible';
}

}

function OpenWindow(PageName,PageFrame,PageProperties) { //v2.0
  PageProperties= PageProperties +',scrollbars=1,resizable=1'
  MyWindow = window.open (PageName,PageFrame,PageProperties)
}

function download_document(octl,newwindow)
{
	oselect = octl //getMyHTMLElement(sctlname)
	if (oselect != null)
	{
		if(oselect.selectedIndex>=0){
			sfilename = oselect.options[oselect.selectedIndex].value
			stitle = oselect.options[oselect.selectedIndex].text}
		if (sfilename!='')
		{
			sfilename = m_sstore_url + 'downloads/' + sfilename
			if (newwindow==1){
				open_win(m_sstore_url + 'download.asp?filename=' + escape(sfilename) +'&title=' + escape(stitle),'download','scrollbars=1,resizable=1,left=100,top=100,width=700,height=500')
				}
			else
				window.location = sfilename
		}
	}
}

function hideTables(tableToHide,indexNo){
if (document.all){
prefix = "document.all";}
else if (document.layers){
prefix = "document.layers";}
holder = eval(prefix)

for(i=1;i<indexNo+1;i++){

	if (prefix == "document.all"){
		holder[tableToHide + i].style.visibility = 'hidden';}
	else if (prefix == "document.layers"){
		holder[tableToHide + i].visibility = 'hidden';}
}

}




function hideTable(tableToHide){
//alert(tableToHide)
if (document.all){
prefix = "document.all";}
else if (document.layers){
prefix = "document.layers";}
holder = eval(prefix)
if (prefix == "document.all"){
holder[tableToHide].style.visibility = 'hidden';}
else if (prefix == "document.layers"){
holder[tableToHide].visibility = 'hidden';}
}

function switchTable(tableToShow){
	if (document.all){
		prefix = "document.all";}
	else if (document.layers){
		prefix = "document.layers";}
	holder = eval(prefix)
	if (prefix == "document.all"){
		if (holder[tableToShow].style.visibility == 'visible'){
			hideTable(tableToShow)
		}
		else{
			showTable(tableToShow)
		}
	}
	else if (prefix == "document.layers"){
		if (holder[tableToShow].visibility == 'visible'){
			hideTable(tableToShow)
		}
		else{
			showTable(tableToShow)
		}
	}
}



function showTable(tableToShow){

	if (document.all){
	prefix = "document.all";}
	else if (document.layers){
	prefix = "document.layers";}
	holder = eval(prefix)
	if (prefix == "document.all"){
	holder[tableToShow].style.visibility = 'visible';}
	else if (prefix == "document.layers"){
	holder[tableToShow].visibility = 'visible';}
}


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,a=MM_preloadImages.arguments; for(i=0; i<a.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) { //v3.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); 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];}
}

// Paraspar's Preload Image Function //
function preloadImage(imageFile)
// The idea behind this is that we can preload all the images
// into an array, we can then circulate through the array at a later
// stage in order to find the specific image we want and load it from
// the array.

{
	if (document.images) {
	// Only run if document.images is supported

		if (document.imageArray==null) document.imageArray = new Array();
		//If the array does not exist, create it.
		
		var arrayLength = document.imageArray.length;
		// Calculate the current length of the array so we can add to it.
		
		document.imageArray[arrayLength] = imageFile;
		document.imageArray[arrayLength + 1] = new Image();
		document.imageArray[arrayLength + 1].src = imageFile; 
		// The even integer part of the array adds the image name
		// The odd integer part of the array adds the image object
		// (i.e. preloads the image into memory).

	}
}



function swapImage(imageName,imageFile)
{
//alert(imageName)
	var swapImageName = eval('document.' + imageName);
	swapImageName.src = imageFile;
	// Replaces the current image with a selected image
	// The images are already preloaded, and therefore can be swapped
	// without reference to the array.
}


function getTop(item){
var top =0;
var mywhere;
mywhere = document.all[item];
	while (mywhere.tagName.toLowerCase() != 'body')
	{
	top += mywhere.offsetTop;
	mywhere = mywhere.offsetParent;
	}
return top;
}
function getLeft(item){
var left =0;
var mywhere;
mywhere = document.all[item];
	while (mywhere.tagName.toLowerCase() != 'body')
	{
	left += mywhere.offsetLeft;
	mywhere = mywhere.offsetParent;
	}
return left;
}


function showTableMousePosition(tableToShow,position){
	if (document.all){
		prefix = "document.all";}
	else if (document.layers){
		prefix = "document.layers";}
	holder = eval(prefix)

	if (prefix == "document.all"){
		holder[tableToShow].style.top = yMousePos;
		holder[tableToShow].style.left = xMousePos; 
	}
	else if (prefix == "document.layers"){
		holder[tableToShow].top = yMousePos;
		holder[tableToShow].left = xMousePos;
	}
	showTable(tableToShow)
}

function printPage(){
window.print()
}


function addToFavorite(urlToAdd,titleToAdd)
{
	//window.external.AddFavorite(urlToAdd,titleToAdd)
	
    if (window.sidebar) {
        window.sidebar.addPanel(titleToAdd, urlToAdd,"");
    } else if( document.all && navigator.appName=="Microsoft Internet Explorer") {
        window.external.AddFavorite( urlToAdd, titleToAdd);
    }	
    else  {
		alert("Press CTRL-D (Firefox/Mozilla/Safari/Opera)")
    }
}


var folderX = ''
			function expandit2(curobj,showReq,forceShow){
				folderX=document.all[curobj.sourceIndex+showReq].style
					if (folderX.display=="none")
						folderX.display=""
					else
						folderX.display="none"
				if (forceShow == 1){folderX.display=""}
			}

function swapPlusFlags2(curobj,path){
			//curobj=document.all[curobj.sourceIndex+1]
			alert('path')
			if (curobj.src == path + "images/plus.gif"){
			curobj.src = path + "images/minus.gif";
			}
			else{
			curobj.src = path +  "images/plus.gif";
			}
			}

function ShowMessages(visibility) {

if (visibility == 'show') {
window.document.all.messageEditText.style.visibility='visible'
}else
{
window.document.all.messageEditText.style.visibility='hidden'
}
}

function Showfav(visibility) {

if (visibility == 'show') {
window.document.all.fav_layer.style.visibility='visible'
}else
{
window.document.all.fav_layer.style.visibility='hidden'
}
}


function setMenuScroll(td,table,maxSize){
	if (document.all[table].style.visibility == 'hidden')
		{
		document.all[table].style.height=1
		openScrollBoxMenu(table)
		setMenu(td,table)
		}
	}

function hideMenuScroll(table){
	hideMenu()
}

function openScrollBoxMenu(currentOptionBox)
	{
	if (parseInt(document.all[currentOptionBox].style.height) < 201)
		{
		document.all[currentOptionBox].style.height = (parseInt(document.all[currentOptionBox].style.height)+ 2) + 'px'
		timeO = setTimeout("openScrollBoxMenu('"+currentOptionBox+"')",1)
		}
	else{
	clearTimeout(timeO)
	}
	}


function open_win(url,wname,attr)
{
	if (wname=='undefined') wname = "win"
	if (attr=='undefined') attr = "toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=0,resizable=0,width=645,height=540"
	var new_win = window.open(url, wname, attr);
	new_win.focus();
}  
function redirectToValue(curObj)
{
	pathRedir = curObj.options[curObj.selectedIndex].value;
	if (pathRedir != "") {document.location.href = pathRedir}
}


function addall_products()
{
	var oformall = document.forms['frmaddallprod']
	var sskulist = '';
	var i=0,j=0;
	var aforms = oformall.formscount.value.split(',')
	var oform;
	var lqty=1;
	var sqtyobj='';
	//format parentguid|sku|quantity|sku display Type|text message
	//sku display type is used only for text message type
	for(i=0;i<=aforms.length-1;i++)
	{
		if (aforms[i]=='') continue;
		oform = document.forms[aforms[i]]
		askus = oform.skudetail.value.split(',')
		for(j=0;j<=askus.length-1;j++)
		{
			skudet = askus[j].split('=')
			octl = eval(oform.name + '.' + skudet[0])
			if(skudet[1]=='text')
			{
				sskulist = sskulist + octl.value + '|' + lqty + '#'
			}
			else if(skudet[1]=='radio')
			{
				for(k=0;k<=octl.length-1;k++) 
				{
					if(octl[k].checked & octl[k].value!='' )  
						sskulist = sskulist + octl[k].value + '|' + lqty +  '#'
				}
			}
			else if(skudet[1]=='select')
			{
					if(octl.selectedIndex>=0 && octl.options[octl.selectedIndex].value!='') 
						sskulist = sskulist + octl.options[octl.selectedIndex].value + '|' + lqty +  '#'
			}
			else if(skudet[1]=='checkbox')
			{
				if (isNaN(octl.length))
				{
					if(octl.checked && octl.value!='') 
						{sskulist = sskulist + octl.value + '|' + lqty +  '#'}
				}
				else				
				{
					for(k=0;k<=octl.length-1;k++) 
					{
						if(octl[k].checked && octl[k].value!='') 
							{sskulist = sskulist + octl[k].value + '|' + lqty +  '#'}
					}				
						
				}
			}						
			else if(skudet[1]=='message')
			{
				octltxt = eval(oform.name + '.' + 'message' + skudet[0].substring(3,skudet[0].length))
				if (octltxt.value!='')
				{
					sskulist = sskulist + octl.value.replace('%QTY%',lqty) +  '|' + octltxt.value + '#'
				}
			}
			lqty = 1
		}
	}
	oformall.skulist.value = sskulist
	oformall.submit()
}

function addprod_to_basket(sformname)
{
	var oform = document.forms[sformname]
	oform.submit()
}

function addprod_to_wishlist(sformname,surl)
{
	var oform = document.forms[sformname]
	oform.action = surl;
	oform.submit()
}


function limittext(field, maxlimit) 
{
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);

}


function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
    }
//window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;

}

function popUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin"; 
}
			
function popUp2(url,w,h) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h);
	self.name = "mainWin"; 
}


function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function CommaFormatted(amount)
{
	var delimiter = ",";
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      var i = s.length - 1;       // Get length of string

      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;

      s = s.substring(0, i+1);
   }

   return s;
}

function Trim(str)
{
   return RTrim(LTrim(str));
}

function getMyHTMLElement(sid)
{
	var oelement;
	if(BROWSER_VER==BROWSER_IE4)
		oelement = document.all[sid]
	else if(BROWSER_VER==BROWSER_NN4)
		oelement = document.layers[sid]
	else if(BROWSER_VER==BROWSER_IE)
		oelement = document.getElementById(sid)
	else
		oelement = document.getElementById(sid)
	return(oelement)
}


function showDisplayTable(tableToShow){
	getMyHTMLElement(tableToShow).style.display=''
}

function hideDisplayTable(tableToHide){
	getMyHTMLElement(tableToHide).style.display='none'
}

function replaceString(aSearch, aFind, aReplace)
    {
    result = aSearch;
    if (result != null && result.length > 0)
        {
        a = 0;
        b = 0;
        while (true)
            {
            a = result.indexOf(aFind, b);
            if (a != -1)
                {
                result = result.substring(0, a) + aReplace + result.substring(a + aFind.length);
                b = a + aReplace.length;
            }
            else
            break;
        }
    }
    return result;
}

//Sudheer Woosa on 19th Nov 2009
//aCharList - Characters to be searched for replacement has to be | separated. Ex - ;|<|>
//aReplace -  Characters to be replaced with has to be | separated. Ex - _||
// ; replaced with _ and < > replaced with space
//If the replacement character is same for all the characters then use one character '.'
function replaceSpecChar4rmString(aSearch, aCharList, aReplace) { 
   
    result = aSearch;
    var sReplace;
    var aFind = aCharList.split("|"); 
    var aReplace = aReplace.split("|"); 
   
    var iCntr = 0;
    if (result != null && result.length > 0) {
        a = 0;
        b = 0;    
        for (iCntr;iCntr < aFind.length;iCntr++)
        {
           while (true) {
            a = result.indexOf(aFind[iCntr], b);           
            if (a != -1) { 
                if (aReplace.length > 0)
                {
                    if (aReplace[iCntr] == 'space')
                    {   
                        aReplace[iCntr] = ' '; 
                        sReplace = aReplace[iCntr];
                    }
                    else
                    {sReplace = aReplace[iCntr];}
                }
                else
                {sReplace = aReplace;}
                result = result.substring(0, a) + sReplace + result.substring(a + aFind[iCntr].length);                
                b = a + sReplace.length;
            }
            else
                break;
            }
        }
        
    }
    return result;
}

//-->
