var rightCaret = String.fromCharCode (62);

function openWin( windowURL, windowName, windowFeatures )
{return window.open( windowURL, windowName, windowFeatures );}
 
function SubmitRec(frm){frm.submit();}

function displayChildren(sMenu){
   var d = document.getElementById(sMenu);
   if (d.className == "clsHiddenMenu")
      d.className = "clsVisibleMenu";
   else
      d.className = "clsHiddenMenu";
}
function LaunchImageManager(){
   window.showModalDialog("/admin/imageManager.asp", "select:no", "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
}  
function LaunchResourceManager(){ 
   window.showModalDialog("/admin/resourceManager.asp", "select:no", "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:450px;");
}  
function pickImageFile(el){
   var sResult = window.showModalDialog("/admin/imageManager.asp", "value:" + el.value, "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
   if (sResult != "cancel") el.value = sResult;
}   
function pickResourceFile(el, dir){
   var args = "value:" + el.value;
   if (dir)
      args += ";root:" + dir;
   var sResult = window.showModalDialog("/admin/resourceManager.asp", args, "resizable:no; help:no; status:no; scroll:no; font-size:14px; dialogWidth:700px; dialogHeight:520px;");
   if (sResult != "cancel") el.value = sResult;
}

function viewFile(el){
   if (el.value != "")
      window.open(el.value);
   else
      alert("Please select a file first.");
}
function clearSetting(el){
   el.value = "";
}		
function checkName(el)
{
	var allowKey = false;
	var keyCode = window.event.keyCode;
	switch (true)
	{
		case (el.value.length >= 50):
			allowKey = false;
			break;
		case (keyCode == 45):
		case ((keyCode >= 48) && (keyCode <= 57)): 
		case ((keyCode >= 65) && (keyCode <= 90)):
		case ((keyCode >= 97) && (keyCode <= 122)):
			allowKey = true;
			break;
		default:
			allowKey = false;
			break;
	}
	window.event.returnValue = allowKey;
}
function checkName2(el)
{

}
function clearTaxJur(type)
{

}
function checkKey(){
   var e = window.event;
   if (e.keyCode == 13) 
      submitForm();
   e.cancelBubble = true;
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
function RefreshImage(valImageId)
{
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
var target = '';
var urlParams = {};
function serializeLink(href) {
	var e,
       d = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
       q = href,
		 r = /\?/, //split on the ?
       r2 = /([^&=]+)=?([^&]*)/g;
		
	//q[0] contains the /url
	//q[1] contains the querystring
	q = q.split(r)

	target = q[0];
	while (e = r2.exec(q[1]))
		urlParams[d(e[1])] = d(e[2]);
}
function setItemCount(data){
	var itemCount = $(data).find('count').text();
	var cartTotal = $(data).find('total').text();
	if(itemCount != 0){
		$('a#myMiniCart').html('<span id="cartText">My Cart (<span id="miniCartCount">' + itemCount + '</span>)</span>');
		if($('a#myMiniCart').siblings('span#miniCartTotal').length == 0)
			$('a#myMiniCart').after('<span id="miniCartTotal">Total: ' + cartTotal + '</span>');
		else
			$('#miniCartTotal').text('Total: ' + cartTotal);
	}else{
		$('a#myMiniCart').html('<span id="cartText">My Cart</span><span id="miniClose">Close</span>');
		$('span#miniCartTotal').remove();
	}
	$('#cartText').show();
	$('#miniClose').hide();
	if (itemCount == 0)
		$('li#checkoutLinkButton').removeClass('checkoutLinkButtonHighlight');
	else
		$('li#checkoutLinkButton').addClass('checkoutLinkButtonHighlight');
	
}
function setMiniCartDetails(data){
	var details = $(data).find('details').text();
	$.fancybox(
		details,
		{

		}
	);

}
