// JavaScript Document
popUpWin = 0;
function popUpWindow(URLStr, title, left, top, width, height,id)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  //alert(URLStr);
  popUpWin = open(URLStr, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollBars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  
}

/////////////////// Pop Up window ///////////////////////
function popopen(a)
{
	window.open("popup.htm?"+a,"","menubar=0,resizable=0,location=0,status=0,scrollbars=0");
}

///////////////////////////////////////////////////////

function popUpWindowMenubar(URLStr, title, left, top, width, height,id)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, title, 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollBars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


function popUpWindow_scroll(URLStr, title, left, top, width, height,id)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollBars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function popUpWindowAll(URLStr, title, left, top, width, height,id)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, title, 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollBars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


	
	
function cNum(e) {
	var strCheck = '0123456789\b\t	 ';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 0 || whichCode == 13)
	{
		return true ;		
	}
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
}

function cNumPhone(e) {
	var strCheck = '0123456789\b\t	 +()[]-';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 0 || whichCode == 13)
	{
		return true ;		
	}
	key = String.fromCharCode(whichCode);  // Get key value from key code
	if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
}


// ==========================================================================
// Fuctions to mimic LTrim, RTrim, and Trim...

// Author          Aurélien Tisné(CS)
// Date            03 avr. 2003 23:11:39
// Last Update     $Date$
// Version         $Revision$
// ==========================================================================

// --------------------------------------------------------------------------
// Remove leading blanks from our string.

// I               str - the string we want to LTrim
// Return          the input string without any leading whitespace

// Date            03 avr. 2003 23:12:13
// Author          Aurélien Tisné(CS)
// --------------------------------------------------------------------------
function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

// --------------------------------------------------------------------------
// Remove trailing blanks from our string.

// I               str - the string we want to RTrim
// Return          the input string without any trailing whitespace

// Date            03 avr. 2003 23:13:50
// Author          Aurélien Tisné(CS)
// --------------------------------------------------------------------------
function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}

function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;

      }

// --------------------------------------------------------------------------
// Remove trailing and leading blanks from our string.

// I               str - the string we want to Trim
// Return          the trimmed input string

// Date            03 avr. 2003 23:15:09
// Author          Aurélien Tisné(CS)
// --------------------------------------------------------------------------
function trim(str)
{
  return RTrim(LTrim(str));
}


/* For Ajax */
/*
{NY notes}

Guys I m  using this for cross browser usablity and to make http calls more reliable. --ny
Please follow the comments..
*/
function yconnect(url,frm,cnt)
{

    ny = new Yconnect(url,frm,cnt);
	    ny.SimpleResponse();

////show the result in this content
//    var responseSuccess = function(o){ 
//        document.getElementById(cnt).innerHTML=o.responseText;
//		
//    }
//
////if any failure show msg 
//    var responseFailure = function(o){ 
//        alert("XMLHTTPRequest Failure");
//    }
//
////used to handle call back events     
//    var callback =
//    {
//        success:responseSuccess,
//        failure:responseFailure
//    }
//
//
//
//// Create object and intiate connection. 	
//
//	if(frm != ''){
//		// set the from where you need to get the data 
//		YAHOO.util.Connect.setForm(frm);
//		var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback,null);
//	}else{
//		var cObj = YAHOO.util.Connect.asyncRequest('GET', url, callback,null);
//	}
//
//
//
//
////This is to check the connection status 
//	var callStatus = YAHOO.util.Connect.isCallInProgress(cObj);
//
//// check for the status and show loading information 
//	if(callStatus){
//		/*document.getElementById(cnt).innerHTML="<span style='font-family:Arial,Helvetica, sans-serif;font-size:10px;font-weight:bold;'><img src='images/loading.gif' align='absmiddle' border='0'>&nbsp; Please wait product loading...</span>";*/
//	}
	
}	
// This fucntion is used to remoev item from the cart
function removeItem(id,divname)
{
	var msg = "Warning : Deleting Item From the Cart \nAre you sure you want to delete this item?";
	var conf = confirm(msg);		
	if(conf) 
	{
		var mode = 'remove_item';
		cart = new Yconnect('ajaxfiles/remove_item_cart.php?mode='+mode+'&id='+id,'',divname);
		cart.SimpleResponse();
		var mode = 'show_items';
		var l = 'ajaxfiles/remove_item_cart.php';
		Ymulti_update[0] = l+"?id="+id+"&mode="+mode+",,show_items";
	}
	else 
	{
		return false;
	}
		
}