﻿// JScript File

//Master page scripts


function findtxt(str)
{

    if (str==null || str =='')
    {
        return;
    }
    var imgs,i;
    imgs=document.getElementsByTagName('span');
 
    for(i in imgs)
    {
        //if(imgs[i].innerHTML == str )
        if (imgs[i].innerHTML!=null) 
        {    
            if  (imgs[i].innerHTML.search(str)!=-1)
            {
                //alert (imgs[i].id);
                //imgs[i].style.color="red";
                //document.getElementById(imgs[i].id).setAttribute("className","SearchSelectedText");
                document.getElementById(imgs[i].id).setAttribute("className","SearchSelectedText");
            }
            else
            {
                //document.getElementById(imgs[i].id).setAttribute("className","UserText");
            }
        }        
        
    }
}




var TRange=null

function findString (str) {
 if (parseInt(navigator.appVersion)<4) return;
 var strFound;
 if (navigator.appName=="Netscape") {

  // NAVIGATOR-SPECIFIC CODE

  strFound=self.find(str);
  if (!strFound) {
   strFound=self.find(str,0,1)
   while (self.find(str,0,1)) continue
  }
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {

  // EXPLORER-SPECIFIC CODE

  if (TRange!=null) {
   TRange.collapse(false)
   strFound=TRange.findText(str)
   if (strFound) TRange.select()
   //TRange.select.style.color="red";
  }
  if (TRange==null || strFound==0) {
   TRange=self.document.body.createTextRange()
   strFound=TRange.findText(str)
   //TRange.select.style.color="red";
   if (strFound) TRange.select()
  }
 }
 if (!strFound) alert ("String '"+str+"' not found!")
}

function showLogInTd(objid, txtobjid)
{   
    var obj =  document.getElementById(objid);
    var lnk =  document.getElementById(txtobjid);
    
    
    if (obj.style.display=='block')
    {
        lnk.innerText ="LogIn +";
        lnk.toolTip="asd";
        obj.style.display='none';
    }
    else
    {
        lnk.innerText ="LogIn -";
        obj.style.display='block';
    }  
}

function clearTextFromLabel(lblBx)
{
    document.getElementById(lblBx).innerText="";
}

function hideLinkButton(lb)
{
    document.getElementById(lb).style.display = 'none';
}

function clearText(txtBx)
{
    document.getElementById(txtBx).value="";
}

function hideTd(objid)
{    
    document.getElementById(objid).style.display='none';    
}
///////////////End MasterPage Scripts

function updateDiscountTbs()
{
    document.getDocumentById();
}

function GetTotal(tbQty, lblPrice, lblTotal, lblGrandTotal)     
{    
    //debugger;

    qty = document.getElementById(tbQty);
    price = document.getElementById(lblPrice);
    total = document.getElementById(lblTotal);
    grand = document.getElementById(lblGrandTotal);
        
    var priceChange = qty.value * price.innerText - total.innerText;     
    total.innerText = qty.value * price.innerText;    
    grand.innerText = calcTotal();
}


function CheckAdmin(obj)
{
    var e = document.getElementById(obj);
    var strUser = e.options[e.selectedIndex].text;    
    if (strUser=='Admin')
    {
        return confirm ('You are giving this user Administrator rights. Proceed?');
    }
}

function SetFlashObjects()
{
    objects = document.getElementsByTagName("object");
    for (var i = 0; i < objects.length; i++)
    {
        objects[i].outerHTML = objects[i].outerHTML;
    }
}

function onMouseOverCart(objid)
{
    image = document.getElementById(objid);        
    image.src = addImg.src;
}

function onMouseOutCart(objid)
{
    image = document.getElementById(objid);    
    image.src=cartImg.src;
}

var addImg = new Image;
var cartImg = new Image;
addImg.src = "Images/add_2.jpg";
cartImg.src = "Images/add_bg.gif";

//onload = ;