﻿
// Do not delete the code yet. Will delete the code later
function checkOutButtonClick()
{
    isCheckOutButtonClicked  = true;
}

function CheckCookies()
{
 /* check for a cookie */
  if (document.cookie != "") 
  {
  }
  else
  {
   var applicationName = pathOnly(document.location.pathname);
   var redirectURL = "http://" + document.location.hostname + "/" + "NotSupported.aspx?errMsg=CookieNotSupported";
   document.location = redirectURL;
  }
}
document.cookie = 'UserBrowserAccepts' + escape('Cookie');

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*1*30*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function fileOnly(_Str) {
   var theSplit = _Str.lastIndexOf ('/');
   if (theSplit != -1)
      return _Str.substring(theSplit+1);
   else return "";
   }
   
   function pathOnly(_Str) {
   var isAt = _Str.lastIndexOf ("/")
   if (isAt != -1)
      return _Str.substring(0,isAt+1);
   else return "";
   }

function AcceptNumerics(e, exception)
{
    if (e == null)
    {
        return false;
    }

    if(e != null && e.keyCode == 13)
    {
         try
        {
            e.keyCode = null;
        }
        catch(error)
        {
            e.cancelBubble = true;
        }
        return false;
    }
    
    var charList = "0123456789";
    if (exception != null)
        charList += exception;
    var charCode = document.all?e.keyCode:e.which;
    if (charCode == 8 || charCode == 13 || charCode == 0 || (e.ctrlKey && charCode == 118)) // handling new line, backspace, ctrl-V and delete keys for firefox.
        return true;
    return (charList.indexOf(String.fromCharCode(charCode)) != -1);
}

function AcceptNumericQuantity(e, exception)
{
    if (e == null)
    {
        return false;
    }
    if(e != null && e.keyCode == 13)
    {
        try
        {
            e.keyCode = null;
        }
        catch(error)
        {
            e.cancelBubble = true;
        }
        return false;
    }
    

//    if (e.keyCode == 13)
//    {
//       e.cancelBubble = true; 
//       return false;
//    }
    var charList = "0123456789";
    if (exception != null)
        charList += exception;
    var charCode = document.all?e.keyCode:e.which;
    if (charCode == 8 || charCode == 13 || charCode == 0 || (e.ctrlKey && charCode == 118)) // handling new line, backspace, ctrl-V and delete keys for firefox.
        return true;
    return (charList.indexOf(String.fromCharCode(charCode)) != -1);
}

function openNoScrollWindow(url,title,width,height) {
	// read resolution and set variables
	var      x = screen.width;
	var      y = screen.height;
	var    top = parseInt((y-height)/2);
	var   left = parseInt((x-width)/2);
	// open new window and use the variables to position it
	window.open(url,title,'width='+width+',height='+height+',left='+left+',top='+top+',scrollbars=no,resize=yes,resizable=yes,menubar=no,toolbar=no,directories=no');
}

function Toggle(id)
{
    var oItem = document.getElementById(id);
    
    if ( (oItem.style.display == "") || (oItem.style.display == "none") )
    {
        ToggleAllOff();
        oItem.style.display = "block";
    }
    else
    {
        oItem.style.display = "none";
    }
}
function ToggleAllOff()
{
    var myDD = document.getElementsByTagName('dd'); 
    for(var i=0;i<myDD.length;i++){
	   myDD[i].style.display='none';
    }
}

function LaunchHelpSecure(url)
{ 
    new_window = window.open( url, 'HelpWin', 'dependent,status,width=780,height=500,left=0,top=0,scrollbars=1')
}

function LaunchHelp()
{ 
    var url = "../help/Helpdefault.aspx";
    new_window = window.open( url, 'HelpWin', 'dependent,status,width=800,height=500,left=0,top=0,scrollbars=1')
}
function LaunchHelpId(id)
{ 
    var url = "../help/Helpdefault.aspx?hid=" + id+"#pageend";
    new_window = window.open( url, 'HelpWin', 'dependent,status,width=780,height=500,left=0,top=0,scrollbars=1')
}
function LaunchHelpIdOther(id)
{ 
    var url = "../help/Helpdefault.aspx?hid=" + id;
    new_window = window.open( url, 'HelpWin', 'dependent,status,width=780,height=500,left=0,top=0,scrollbars=1')
}
function showHelpId(id)
{
    var oItem = document.getElementById(id);
    oItem.style.display = "block";
} 

/* Edited by preetham, Dt: 20 Feb 2007 */

// Live Chat link
function popitupLC(url)
{    
		newwindow=window.open(url,'popupwindowLC','width=805,height=175,toolbar=0, resizable=1, location=0,directories=0 ,status=0, menubar=0, scrollbars=1, titlebar=0,top=50, left=50');
	if (window.focus) {newwindow.focus()}
	return false;
}

//compare products
function popitupCP(url)
{    
	newwindow=window.open(url,'popupwindowCP','width=795,height=460,toolbar=0, resizable=1, location=0,directories=0 ,status=0, menubar=0, scrollbars=0, titlebar=0,top=50, left=50');
	if (window.focus) {newwindow.focus()}
	return false;
}

// Price Chart -used only in AddToCart.aspx
function popitupPC(url)
{    
	UpdatePriceChartHref(url);
	newwindow=window.open(url,'popupwindowPC','width=330,height=420,scrollbars=no,resizable=no,top=50, left=50,');
	if (window.focus) {newwindow.focus()}
	return false;
}

/* edited by naveen, dt:21 feb 07 */
function openNoScrollWindow(url,title,width,height) {
	// read resolution and set variables
	var      x = screen.width;
	var      y = screen.height;
	var    top = parseInt((y-height)/2);
	var   left = parseInt((x-width)/2);
	// open new window and use the variables to position it
	window.open(url,title,'width='+width+',height='+height+',left='+left+',top='+top+',scrollbars=no,resize=yes,resizable=yes,menubar=no,toolbar=no,directories=no');
}


function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}

//this function is useed to record clicks on hyperlinks for datasheet/whitepaper downloads.
function dcsMultiTrackDownload(downloadUri,pageTitle,downloadType,EnableWebTrendsOnDemand)
{   
    if (EnableWebTrendsOnDemand.toLowerCase() == 'true')
        dcsMultiTrack('DCS.dcsuri',downloadUri, 'WT.ti',pageTitle , 'WT.dl', '20', 'WT.si_n', downloadType, 'WT.si_x','1', 'WT.si_cs', '1');
}

//Method to replace domain names from Uris so that only relative paths are sent to WebTrends
function RemoveDomainFromURI(uri,domainToRemove)
{
    return uri.replace(domainToRemove,'');
}

function showWindowTitle(text) 
{
    window.status = text;
}

function removeWindowTitle() 
{
    window.status = '';
}
