//--------------------------------------------------------------------------------------------------------- Your Custom JS Functions Here -------
function GCS(){
x=document.getElementsByTagName('form')[0];
x.id = "cse-search-box";
x.action = "/Search-Result.htm";
x.submit();
}

function FireKeypress(e, txtObj)
{
    //when enter key pressed
    e = e || window.event;
    var code = e.keyCode || e.which;
   if(code == 13)
      GCS();
}


function MouseOver(id)
{
     document.getElementById(id).className = "current";
}

function MouseOut(id)
{
     document.getElementById(id).className = "";
     nav();
}

function Cart(){ 

this.addData=function(typeName, name, price){
    var url = "/AjaxCart.aspx?option=add&tn=" + encodeURIComponent(typeName) + "&pn=" + encodeURIComponent(name.replace(/\_\_QUOT\_\_/ig, "'")) + "&price=" + price + "&amount=1";
    
    var ia = new IncholAJAX(url);
    ia.RemoteServer(ia);
    IncholAJAX.prototype.ProcessIncholOverride = ProcessIncholOverride_Add;
}
}
var cart= new Cart();

function ProcessIncholOverride_Add()
{
    var responseText = this.GetResponseText();
    if(responseText == "T")
    {
        alert("Item has been added to cart!");
    }
    else
    {
        alert("Failed to add item!");
    }
}

function updatePro(obj, txtId){
    var id = obj.id.split('_')[1];
    var txtObject = document.getElementById(txtId + id);
    var newAmount = txtObject.value;
    if(newAmount == "")
    {
        alert("Quantity can not be blank.");
        txtObject.focus();
        return false;
    }
    if(isNaN(newAmount))
    {
       alert("Quantity must be number.");
       txtObject.select();
       return;
    }

    var url = "/AjaxCart.aspx?option=update&id=" + id + "&amount=" + newAmount;
    var ia = new IncholAJAX(url, id);
    ia.RemoteServer(ia);
    IncholAJAX.prototype.ProcessIncholOverride = ProcessIncholOverride_Update;
}

function ProcessIncholOverride_Update()
{
    var responseText = this.GetResponseText();
    if(responseText == "T")
    {
        alert("Item has been updated to cart!");
        ReloadPage(this.parameter1);
    }
    else
    {
        alert("Failed to update item!");
    }
}

function isdigit(s)
{
    var r,re;
    re = /\d*/i;
    r = s.match(re);
    return (r==s)?1:0;
}

function deletePro(obj){
    var bln = confirm('Are you sure you want to delete this record.');  
    if(bln == false) return;    
    var id = obj.id.split('_')[1];
    var url = "/AjaxCart.aspx?option=delete&id=" + id;
    var ia = new IncholAJAX(url, id);
    ia.RemoteServer(ia);
    IncholAJAX.prototype.ProcessIncholOverride = ProcessIncholOverride_Delete;
}

function ProcessIncholOverride_Delete()
{
    var responseText = this.GetResponseText();
    if(responseText == "T")
    {
        alert("Item has been deleted!");
        ReloadPage(this.parameter1);
    }
    else
    {
        alert("Failed to delete this record!");
    }
}

function ReloadPage(guid)
{
    var url = window.location.href.split('?')[0];
    window.location.href = url + "?guid=" + guid;
}

function playMedia(files,texts,height,width,type,control,title) {
  if(type == "video")
    embedSource(files,texts,height,width,control);
else
    embedSource_Audio(files,height,width,control,title);
}

function embedSource(files,texts,height,width,control)
{
    var html = "<embed src='/media/play.swf' allowFullScreen='true' autoPlay='true' FlashVars='vcastr_file=";
        html += files+ "&vcastr_title=" + texts + "&IsAutoPlay=1' menu='true' quality='high' width='";
        html += width + "' height='" + height + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
        document.getElementById(control).innerHTML = html;
}

function embedSource_Audio(files,height,width,control,title)
{
    var top = (parseInt(height) - 100)/2;
    var left = (parseInt(width) - 300)/2;
    title = "<font style='color:#2F5EC0;font-weight:bold;font-size:16px'>Audio:&nbsp;" + title + "&nbsp;Information</b>";
    var html = "<div style='position:absolute;top:15px;left:15px'>" + title + "</div><div id='S_div' style='position:absolute;top:" + top + "px;left:" + left + "px'><object id='MediaPlayer1' width='300' height='100' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'";
    html += " codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112'";
    html += "align='baseline' border='0' standby='Loading Microsoft Windows Media Player components...' ";
    html += "type='application/x-oleobject'>";
    html += "<param name='URL' value='" + files + "'>"
    html += "<param name='autoStart' value='true'>";
    html += "<param name='invokeURLs' value='false'>";
    html += "<param name='playCount' value='100'>";
    html += "<param name='defaultFrame' value='datawindow'>";
    html += "<embed src='" + files + "' align='baseline' border='0' width='300' height='100'";
    html += " type='application/x-mplayer2'  pluginspage='' name='MediaPlayer1' showcontrols='1' showpositioncontrols='0'";
    html += " showaudiocontrols='1' showtracker='1' showdisplay='0' showstatusbar='1' autosize='0'	showgotobar='0'";
    html += " showcaptioning='0' autostart='1' autorewind='0' animationatstart='0' transparentatstart='0' allowscan='1'";
    html += " enablecontextmenu='1' clicktoplay='0' defaultframe='datawindow' invokeurls='0'></embed></object></div>";
    document.getElementById(control).innerHTML = html;
}

function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else
       return "unknown";
}

function openWindow(url, width, height)
{

var  top=(window.screen.height-height)/2;
  var  left=(window.screen.width-width)/2;
window.open (url, "newwindow", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=no, status=no") 

}











