/************************************************************************/
/*                  START CLEAR FORM FIELDS LOGIN BOX                   */
/************************************************************************/
/*Clear default form value script
If you have set the field's Value so that there is default text in the field, 
this clears the field when the user clicks in it
add:  onFocus="clearText(this)"    to each input tag*/
/* START CLEAR FORM FIELDS */
function clearText(thefield) {
 if (thefield.defaultValue == thefield.value) {
 	thefield.value = "";
 }
}
function restoreText(thefield2) {
 if (thefield2.value == "") {
 	thefield2.value = thefield2.defaultValue;
 }
}

/************************************************************************/
/*                   END CLEAR FORM FIELDS LOGIN BOX                    */
/************************************************************************/


/************************************************************************/
/*                        START BOOKMARK FUNCTION                       */
/************************************************************************/
// This is a cross browser (Firefox 1.x+, IE4+ and Opera7+) 
// script for allowing the user to easily bookmark the site, 
// by clicking on a link on the page.
// Add this to the href link: javascript:bookmarksite('Bookmark Name/Title','URL');
function bookmarksite(title,url){
	if (window.sidebar) // opens firefox bookmark dialogue
	window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print) { // opens opera bookmark dialogue
		var lvll = document.createElement('a');
		lvll.setAttribute('href',url);
		lvll.setAttribute('title',title);
		lvll.setAttribute('rel','sidebar');
		lvll.click();
	} 
	else if(document.all) // opens ie bookmark dialogue
	window.external.AddFavorite(url, title);
}

/************************************************************************/
/*                         END BOOKMARK FUNCTION                        */
/************************************************************************/


/************************************************************************/
/*                         START PRINT FUNCTION                         */
/************************************************************************/
function printme() { 
	window.print(); 
}
/************************************************************************/
/*                          END PRINT FUNCTION                          */
/************************************************************************/



/*########################################*/
/*    START THE FLASH FIX FOR VERISIGN    */
/*########################################*/
/*
       <script type="text/javascript" language="javascript">playSXAFlash();</script>
       <noscript>
        <img src="../images/flash_button_name.jpg" width="531" height="239" alt="You need to have JavaScript enabled in order to view this application" />
       </noscript>
*/
function playVerisign() { 
document.write('<script language="JavaScript" type="text/javascript">  \n');
document.write('var requiredMajorVersion = 6; \n');
document.write('var requiredMinorVersion = 0; \n');
document.write('var requiredRevision = 0; \n');
document.write('var jsVersion = 1.0; \n');
document.write('</script>  \n');
document.write('<script language="VBScript" type="text/vbscript">  \n');
document.write('Function VBGetSwfVer(i)  \n');
document.write('  on error resume next  \n');
document.write('  Dim swControl, swVersion  \n');
document.write('  swVersion = 0  \n');
document.write('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))  \n');
document.write('  if (IsObject(swControl)) then  \n');
document.write('    swVersion = swControl.GetVariable("$version")  \n');
document.write('  end if  \n');
document.write('  VBGetSwfVer = swVersion  \n');
document.write('End Function  \n');
document.write('</script>  \n');
document.write('<script language="JavaScript1.1" type="text/javascript">  \n');
document.write('var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; \n');
document.write('var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; \n');
document.write('var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; \n');
document.write('jsVersion = 1.1; \n');
document.write('function JSGetSwfVer(i) { \n');
document.write('	if (navigator.plugins != null && navigator.plugins.length > 0) { \n');
document.write('		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { \n');
document.write('			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; \n');
document.write('      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; \n');
document.write('			descArray = flashDescription.split(" "); \n');
document.write('			tempArrayMajor = descArray[2].split("."); \n');
document.write('			versionMajor = tempArrayMajor[0]; \n');
document.write('			versionMinor = tempArrayMajor[1]; \n');
document.write('			if ( descArray[3] != "" ) { \n');
document.write('				tempArrayMinor = descArray[3].split("r"); \n');
document.write('			} \n');
document.write('			else { \n');
document.write('				tempArrayMinor = descArray[4].split("r"); \n');
document.write('			} \n');
document.write('      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; \n');
document.write('            flashVer = versionMajor + "." + versionMinor + "." + versionRevision; \n');
document.write('      	} \n');
document.write('		else { \n');
document.write('			flashVer = -1; \n');
document.write('		} \n');
document.write('	} \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; \n');
document.write('	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; \n');
document.write('	else { \n');
document.write('		flashVer = -1; \n');
document.write('	} \n');
document.write('	return flashVer; \n');
document.write('}  \n');
document.write('function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)  {  \n');
document.write(' 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);  \n');
document.write('	for (i=25;i>0;i--) {	  \n');
document.write('		if (isIE && isWin && !isOpera) {  \n');
document.write('			versionStr = VBGetSwfVer(i);  \n');
document.write('		}  \n');
document.write('		else {  \n');
document.write('			versionStr = JSGetSwfVer(i);  \n');		
document.write('		}  \n');
document.write('		if (versionStr == -1 ) {   \n');
document.write('			return false;  \n');
document.write('		}  \n');
document.write('		else if (versionStr != 0) {  \n');
document.write('			if(isIE && isWin && !isOpera) {  \n');
document.write('				tempArray         = versionStr.split(" ");  \n');
document.write('				tempString        = tempArray[1];  \n');
document.write('				versionArray      = tempString .split(",");  \n');				
document.write('			}  \n');
document.write('			else {  \n');
document.write('				versionArray      = versionStr.split(".");  \n');
document.write('			}  \n');
document.write('			versionMajor      = versionArray[0];  \n');
document.write('			versionMinor      = versionArray[1];  \n');
document.write('			versionRevision   = versionArray[2];  \n');
document.write('			versionString     = versionMajor + "." + versionRevision;     \n');
document.write('			versionNum        = parseFloat(versionString);  \n');
document.write('			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {  \n');
document.write('				return true;  \n');
document.write('			}  \n');
document.write('			else {  \n');
document.write('				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	  \n');
document.write('			}  \n');
document.write('		}  \n');
document.write('	}	  \n');
document.write('	return (reqVer ? false : 0.0);  \n');
document.write('}  \n');
// -->
document.write('</script>  \n');
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if(hasRightVersion) { 
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100" height="72" id="getseal_conv" align="middle"> \n');
         document.write('<param name="allowScriptAccess" value="sameDomain" /> \n');
         document.write('<param name="movie" value="js/getseal_conv.swf" /> \n');
         document.write('<param name="menu" value="false" /> \n');
         document.write('<param name="allowFullScreen" value="false" /> \n');
         document.write('<param name="quality" value="high" /> \n');
         document.write('<param name="bgcolor" value="#ffffff" /> \n');
         document.write('<param name="wmode" value="transparent" /> \n');
         document.write('<embed src="js/getseal_conv.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="100" height="72" id="getseal_conv" name="freescore_btn" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> \n');
        document.write('</object>\n');
	}
	else { 
        document.write('<a href="http://www.macromedia.com/go/getflash/" target="_blank">Visit Adobe for the latest plugin</a>\n');
  	}
}
/*######################################*/
/*    END THE FLASH FIX FOR VERISIGN    */
/*######################################*/


/*For netInsight Tracking  on freescore Portal site*/
function ForgotPwd() {
  var sPath = window.location.pathname;
  var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  //alert(sPage);
  ntptEventTag('ev=ForgotPwdClick&linkpage='+sPage+'&linkdesc=ForgotPassword&linkloc=forgotPasswordLink');
  return true;
}

function Login() {
  var sPath = window.location.pathname;
  var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
  //alert(sPage);
  ntptEventTag('ev=LoginClick&linkpage='+sPage+'&linkdesc=Login&linkloc=GoButton');
  //alert(ntptEventTag);
  return true;
}



function shownewwin(windowURL, windowName, windowFeatures) {
	var newWindow = window.open(windowURL, windowName, windowFeatures);
	newWindow.focus(); 
	return;
 }



/* font size adjustment for user */
function setBodyFont(intendedsize) {
	document.getElementsByTagName('body')[0].style.fontSize = intendedsize;
	document.getElementsByTagName('p')[0].style.fontSize = intendedsize;
	document.getElementsByTagName('ul')[0].style.fontSize = intendedsize;
	document.getElementsByTagName('li')[0].style.fontSize = intendedsize;
	document.getElementsByTagName('div')[0].style.fontSize = intendedsize;
	document.getElementsByTagName('span')[0].style.fontSize = intendedsize;
}

/*
<div>Font-size:[<a href='javascript:setBodyFont("16px")'>Bigger</a> | <a href='javascript:setBodyFont("14px")'>Normal</a> | <a href='javascript:setBodyFont("10px")'>Smaller</a>]</div>
*/
function PageLoad(){
	MM_preloadImages(
		'../Images/Catalog/en/btn_fun_nm.png',
		'../Images/Catalog/en/btn_music_nm.png',
		'../Images/Catalog/en/btn_food_nm.png',
		'../Images/Catalog/en/btn_theme_nm.png',
		'../Images/Catalog/en/btn_store_nm.png',
		'../Images/Catalog/en/btn_bonus_nm.png',
		'../Images/Catalog/en/btn_fun_hv.png',
		'../Images/Catalog/en/btn_music_hv.png',
		'../Images/Catalog/en/btn_food_hv.png',
		'../Images/Catalog/en/btn_theme_hv.png',
		'../Images/Catalog/en/btn_store_hv.png',
		'../Images/Catalog/en/btn_bonus_hv.png',
		'../Images/Layout/en/btn_shoppingcart_nm.gif',
		'../Images/Layout/en/btn_myaccount_nm.gif',
		'../Images/Layout/en/btn_logout_nm.gif',
		'../Images/Layout/en/btn_home_nm.gif',
		'../Images/Layout/en/btn_help_nm.gif',
		'../Images/Layout/en/btn_shoppingcart_hv.gif',
		'../Images/Layout/en/btn_myaccount_hv.gif',
		'../Images/Layout/en/btn_logout_hv.gif',
		'../Images/Layout/en/btn_home_hv.gif',
		'../Images/Layout/en/btn_help_hv.gif'
	);
}



/************************************************************************/
/*               START NON-OBTRUSIVE IMAGE SWAP FUNCTION                */
/************************************************************************/
//addEvent by http://ejohn.org/projects/flexible-javascript-events
function addEvent(obj,type,fn) {
	if(obj.attachEvent) {
		obj['e'+type+fn]=fn;
		obj[type+fn]=function(){obj['e'+type+fn](window.event)};
		obj.attachEvent('on'+type,obj[type+fn])
	}
	else {
		obj.addEventListener(type,fn,false)
	}
}
function removeEvent(obj,type,fn) {
	if(obj.detachEvent) {
		obj.detachEvent('on'+type,obj[type+fn]);
		obj[type+fn]=null
	}
	else {
		obj.removeEventListener(type,fn,false)
	}
}

//Non-Obtrusive Image Swap Script V1.1 by Hesido.com 
//(instead of default dreamweaver functions)
//http://www.hesido.com/web.php?page=imageswapping
function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) {
	if(typeof(elem)=='string') {
		elem=document.getElementById(elem)
	}
	if(elem===null) {return}
	var regg=/(.*)(_nm\.)([^\.]{3,4})$/;
	var prel=new Array(),img,imgList,imgsrc,mtchd;
	imgList=elem.getElementsByTagName('img');
	for(var i=0;img=imgList[i];i++) {
		if(!img.rolloverSet&&img.src.match(regg)) {
			mtchd=img.src.match(regg);
			img.hoverSRC=mtchd[1]+'_hv.'+mtchd[3];
			img.outSRC=img.src;
			if(typeof(mouseOver)!='undefined') {
				img.hoverSRC=(mouseOver)?mtchd[1]+'_hv.'+mtchd[3]:
				false;
				img.outSRC=(mouseOut)?mtchd[1]+'_ou.'+mtchd[3]:(mouseOver&&mouseOutRestore)?img.src:false;
				img.mdownSRC=(mouseDown)?mtchd[1]+'_md.'+mtchd[3]:false;
				img.mupSRC=(mouseUp)?mtchd[1]+'_mu.'+mtchd[3]:(mouseOver&&mouseDown&&mouseUpRestore)?img.hoverSRC:(mouseDown&&mouseUpRestore)?img.src:false
			}
			if(img.hoverSRC) {
				preLoadImg(img.hoverSRC);
				img.onmouseover=imgHoverSwap
			}
			if(img.outSRC) {
				preLoadImg(img.outSRC);
				img.onmouseout=imgOutSwap
			}
			if(img.mdownSRC) {
				preLoadImg(img.mdownSRC);
				img.onmousedown=imgMouseDownSwap
			}
			if(img.mupSRC) {
				preLoadImg(img.mupSRC);
				img.onmouseup=imgMouseUpSwap
			}
			img.rolloverSet=true
		}
	}
	function preLoadImg(imgSrc) {
		prel[prel.length]=new Image();
		prel[prel.length-1].src=imgSrc
	}
}
function imgHoverSwap() {
	this.src=this.hoverSRC
}
function imgOutSwap() {
	this.src=this.outSRC
}
function imgMouseDownSwap() {
	this.src=this.mdownSRC
}
function imgMouseUpSwap() {
	this.src=this.mupSRC
}

//add events to window onload
addEvent(window, "load", function(){
  prepareImageSwap("top_menus_wrapper");
  prepareImageSwap("common_top_menu");  
  prepareImageSwap("category_top_menu");
  
  prepareImageSwap("_ctl0_CategoryTopMenu1_948");
  prepareImageSwap("_ctl0_CategoryTopMenu1_949");
  prepareImageSwap("_ctl0_CategoryTopMenu1_950");
  prepareImageSwap("_ctl0_CategoryTopMenu1_951");
  prepareImageSwap("_ctl0_CategoryTopMenu1_954");
  prepareImageSwap("_ctl0_CategoryTopMenu1_956");

  prepareImageSwap("_ctl0_CommonTopMenu1_lnk_commonwebitem_2154");
  prepareImageSwap("_ctl0_CommonTopMenu1_lnk_commonwebitem_2143");
  prepareImageSwap("_ctl0_CommonTopMenu1_lnk_commonwebitem_2141");
  prepareImageSwap("_ctl0_CommonTopMenu1_lnk_commonwebitem_2157");
  prepareImageSwap("_ctl0_CommonTopMenu1_lnk_commonwebitem_2133");

});
/************************************************************************/
/*                END NON-OBTRUSIVE IMAGE SWAP FUNCTION                 */
/************************************************************************/


/*
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) { //v4.01var 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 && d.getElementById) x=d.getElementById(n);
	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];
	}
}
*/


