
//----------------FAQ----------------------------------------------

function InitCtrls()
{
    var nHeight = document.body.scrollHeight;
    var nWidth = document.body.scrollWidth;

    var oContent = FindObject("content", "iframe", parent);
    if (oContent == null || oContent == "")    return ;

    if (nHeight != "" && nHeight > 0)
    {
        var nMaxH = oContent.scrollHeight;
        if (nMaxH < nHeight)
            oContent.height = nHeight;
        else
            oContent.height = nHeight;
    }
    else if (strFrameName == IFRAME_NAME_CONTENT)
    {
        oContent.height = 600;
    }
}

function FindObject(strName, strTagName, oParentObj)
{
    var oCurrObj = "";
    oParentObj = (oParentObj != null)? oParentObj.document : document;
    var oFoundObj = oParentObj.getElementsByTagName(strTagName);

    for (var i=0; i<oFoundObj.length; i++)
    {
        var oTempObj = oFoundObj.item(i);
        if (oTempObj.id == strName)
        {
            oCurrObj = oTempObj;
            break;
        }
    }
    return (oCurrObj);
}

var m_oPrevItems = "";
function ToggleDisplay(oItems)
{
    if (m_oPrevItems != oItems)
        initToggle();

    if (oItems.style.display == "none")
        oItems.style.display = "";
    else
	oItems.style.display = "none";

    m_oPrevItems = oItems;
    InitCtrls();
    return;
}

function initToggle()
{
    if (m_oPrevItems != null && m_oPrevItems != "")
        m_oPrevItems.style.display = "none";
}
//--------------------------------------------------------------
function applyCRFormat(oDiv)
{
    if (typeof(oDiv) == "undefined" || oDiv == null)    return;
    if (oDiv.innerHTML == "")    return;
    
    var strText = oDiv.innerHTML;
    strNewText = strText.replace(/\n/g, "<br>");
   // strNewText = strText.replace(/%0d%0a/g, "<br>");

    alert(strNewText);
    oDiv.innerHTML = strNewText;   

}


//--------------------------------------------------------------
function getArg(theStr, theKey)
{
	var i = theStr.indexOf(theKey);
 	if (i==-1) return "";
 	var subStr = theStr.substr(i+theKey.length+1);
 	i = subStr.indexOf('&');
 	if (i != -1)
    	return(subStr.slice(0,i));
 	else
    	return(subStr);
}

//--------------------------------------------------------------
function AddMainImage(oNameArray)
{
    var strTableTag = "";
    for(i=1;i<oNameArray.length;i++)
    {
       
        if(oNameArray[i] != "")
        {
            strTableTag += "<img src='" + oNameArray[i] + "'  border='0'>";
        }
        else
        {
            strTableTag += "";
        }
    }
    document.write(strTableTag);
}

//--------------------------------------------------------------
function AddHref(serial_no)
{
    var strSNLink = "";
    if(serial_no != "")
        strSNLink = "<a href='promotion.aspx?serial_no=" + serial_no + "' >more...</a>";
    document.write(strSNLink);
}

//--------------------------------------------------------------
function AddHrefRec(strLink) //recommen01.aspx
{
    var strSNLink = "";
    if(strLink != "")
        strSNLink = "<a href='" + strLink + "' target='_blank'>more...</a>";
    document.write(strSNLink);
}

function DisCountPrice(strPrice, strSPrice)
{
      if(strPrice == "")
          strPrice = "0";
      if(strSPrice == "")
          strSPrice = "0";
      var nDiscount = parseInt(strPrice) - parseInt(strSPrice);
      if(nDiscount > 0)
          strDiscount = nDiscount;
      else
          strDiscount = "0";
      document.write(strDiscount);
      
}



