function changeFrames(contentURL, paramURL, to) {	
    //for netvigation on the same page    
    if(top.document.getElementById("mainFrame")!=null){	
        if(contentURL.indexOf(top.mainFrame.location.pathname) > -1) {
            top.mainFrame.location.href = contentURL;
            return;
        }
    }
    if(to == 0){
        if(contentURL.indexOf("#") > -1) {
            var url = contentURL.split("#");
            contentURL = url[0] + "&anchor=" + url[1];
        } //if
        top.location.href = "/its/account/productService.do?content="+contentURL+"&index="+paramURL;
    }else{
        top.leftFrame.location.href = "/its/account/productService/menu.do?index="+paramURL;
        top.mainFrame.location.href = contentURL;
    }
}

function openPopupWindow(url, windowName, width, height) {
   return openPopupWindow(url, windowName, width, height, "yes");
}

function openPopupWindow(url, windowName, width, height, fixed) {
   popupwin = window.open(url,windowName,'scrollbars=yes,resizable=' + fixed + ',toolbar=no,width='+width+', height='+height+',left=0,top=0');
   popupwin.focus();
   return popupwin;
}

function popupFAQ(name, height) {
   var s = "/its/help/faq/content.do" + "#" + name;
   var win = openPopupWindow(s,'FAQ',780,height, "yes");
   win.resizeTo(780, height);
   win.focus();
}

function openRemoteWindow(url, name, width, height,sroll) {
    var s;
    if (scroll==null || scroll=="") {
      s="no";
    } else {
      s="yes";
    }

   var feature = "scrollbars=" +s+ ",resizable=yes,width=" + width + ",height=" + height
               + ",alwaysRaised=yes,left=0,top=0,screenX=0,screenY=0;";

   promotionWin = window.open(url, name, feature);
   if (promotionWin.opener == null) promotionWin.opener = window;
   // window.focus();
}

function openerToURL(url) {
   if (opener == null) {
      window.location=url;
   } else if (opener.closed) {
      var win = window.open(url,'new_win','');
      win.focus();
   } else {
         opener.top.location=url;
         opener.top.focus();
   }
}

function openWinStat(theURL,winName,features)  {
    if (!features || features=="")  {
     features = 'scrollbars=yes, resizable=yes, toolbar=no,width=780, height=580,alwaysRaised=yes,left=0,top=0,screenX=0,screenY=0';
    }
    orderWin = window.open(theURL,winName,features);
    //if (orderWin.opener == null) orderWin.opener = window;
    orderWin.focus();
}

function openPopup(url, windowName, width, height, left, top) {
    return window.open(url,windowName,'scrollbars=no,resizable=no,toolbar=no,width='+width+', height='+height+',left='+left+',top='+top);
}

function getParamFromURL(name) {
   var l_href = location.href;
   var l_href = l_href.split("?");
   var subMenu = "0";
   if(l_href.length>1){
      for (var i = 1; i<= l_href.length-1; i++) {
         var l_param = l_href[i].split("=");
         if(l_param.length>1){
            if (l_param[0] == name) {
               return l_param[1];
            }
         }
      }
   }
}

function isValidCharacterOrNumeric(str) {
   //search the string to see if it only contains characters or numbers
   var i;
   for (i=0; i < str.length; i ++) {
      var c = str.charAt(i);
      //alert("check char " + c);
         //if a non-character found
         if (  !(((c>= "a") && (c <= "z")) || (( c >= "A") && (c <= "Z"))) && ((c < '0') || ( c > '9'))) {
            return false;
         }//if
   }//for
   return true;
}//isCharacter

function isValidCharacterOrNumeric(str) {
   //search the string to see if it only contains characters or numbers
   var i;
   for (i=0; i < str.length; i ++) {
      var c = str.charAt(i);
      //alert("check char " + c);
         //if a non-character found
         if (  !(((c>= "a") && (c <= "z")) || (( c >= "A") && (c <= "Z"))) && ((c < '0') || ( c > '9'))) {
            return false;
         }//if
   }//for
   return true;
}//isCharacter

function openAcrobatEng()
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var sWidth = 640;
	var sHeight = 480;
	var sLeft = (screenWidth-sWidth)/2;
	var sTop = (screenHeight-sHeight)/2;
	
  	orderWin = window.open("http://www.adobe.com/products/acrobat/readstep2_allversions.html", "popup", "scrollbars=yes, resizable=yes, toolbar=yes, location=yes, menubar=yes, status=yes, width="+sWidth+", height="+sHeight+",alwaysRaised=yes,left="+sLeft+",top="+sTop+",screenX="+sLeft+",screenY="+sTop);
	if (orderWin.opener == null) orderWin.opener = window;
	orderWin.focus();
}

function openAcrobatCht()
{
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var sWidth = 640;
	var sHeight = 480;
	var sLeft = (screenWidth-sWidth)/2;
	var sTop = (screenHeight-sHeight)/2;
	
  	orderWin = window.open("http://www.chinese-t.adobe.com/products/acrobat/readstep2_allversions.html", "popup", "scrollbars=yes, resizable=yes, toolbar=yes, location=yes, menubar=yes, status=yes, width="+sWidth+", height="+sHeight+",alwaysRaised=yes,left="+sLeft+",top="+sTop+",screenX="+sLeft+",screenY="+sTop);
	if (orderWin.opener == null) orderWin.opener = window;
	orderWin.focus();
}

function firstSubmit(cnt) {
    // cnt is the SubmitCount object inside the form. Default value is 1.
    var num = parseInt(cnt.value);
    num = num - 1;
    cnt.value = num;
    if (num == 0) {
        return true;
    }
    return false;
}

function tradingDetails() {
  openPopupWindow("/its/market/bullionFaq.do",'tradingDetails',770,500);
}

function changeColour(elementId) {
	var interval = 700;
	var red = "#ff0000", defaultColour = "#ffffff";
	if (document.getElementById) {
		var element = document.getElementById(elementId);
		element.style.color = (element.style.color == red) ? defaultColour : red;
		setTimeout("changeColour('" + elementId + "')", interval);
	}
}
