//
//
	function shipping_info()
	{
	   window.open("http://www.ecomputerdepot.com/contents/ShippingInfo.html","shippingInfo", "width=770, height=500,toolbar=0, left=0,top=0, menubar=no, scrollbars=yes, resizable=yes");
	}

	function Trim(TRIM_VALUE)
	{
		if(TRIM_VALUE.length < 1)
		{
			return"";
		}
		TRIM_VALUE = RTrim(TRIM_VALUE);
		TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE=="")
		{
			return "";
		}
		else
		{
			return TRIM_VALUE;
		}
	}

	//////////////////

	function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0)
		{
			return"";
		}
		var iTemp = v_length -1;
		while(iTemp > -1)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;
		}
		return strTemp;
	}

	//////////////////

	function LTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		if(v_length < 1)
		{
			return"";
		}
		var v_length = VALUE.length;
		var strTemp = "";
		var iTemp = 0;
		while(iTemp < v_length)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
				///
			}
			else
			{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}
		return strTemp;
	}
	  
	//////////////////

	function check_email(emailaddress)
	{
		var emailStr = emailaddress;
		var checkTLD=1;
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

		var validChars="\[^\\s" + specialChars + "\]";

		var quotedUser="(\"[^\"]*\")";

		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';

		var word="(" + atom + "|" + quotedUser + ")";

		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

		var matchArray=emailStr.match(emailPat);

		if (matchArray==null) 
		{
			alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
			
		var user=matchArray[1];
		var domain=matchArray[2];

		for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
		alert("The username contains invalid characters.");
		return false;
		   }
		}
		for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
		alert("The domain name contains invalid characters.");
		return false;
		   }
		}

		if (user.match(userPat)==null) {

		alert("The email doesn't seem to be valid.");
		return false;
		}

		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {

		for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
		alert("Destination IP address is invalid!");
		return false;
		   }
		}
		return;
		}
				 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
		alert("The domain name does not seem to be valid.");
		return false;
		   }
		}

		if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
		}

		if (len<2) {
		alert("This address is missing a hostname!");
		return false;
		}
		return true;
	}  
//////////////////////////////

	function setemail()
	{
		if(document.frmsubscribe.email.value=="email address")
		{
			document.frmsubscribe.email.value="";
		}
	}

	function getemail()
	{
		if(document.frmsubscribe.email.value=="email address" || Trim(document.frmsubscribe.email.value)=="")
		{
			document.frmsubscribe.email.value="email address";
		}
	}

	function subscribe()
	{
		if(Trim(document.frmsubscribe.email.value)=="")
		{
			alert("Please enter your email address to receive best deals");
			document.frmsubscribe.email.focus();
			return;
		}
		else if(check_email(Trim(document.frmsubscribe.email.value)))
		{
			document.frmsubscribe.submit();
		}
	}


	function dealers()
	{
		if(Trim(document.frmdealers.dealer_code.value)=='')
		{
			alert("Dealer code cannot be empty");
			document.frmdealers.dealer_code.focus();
		}	
		else
		{
			document.frmdealers.submit();
		}
	}


function print_invoice(url)
{
	window.open(url,"print_inv", "width=800, height=600,toolbar=0, left=0,top=0, menubar=yes, scrollbars=yes, resizable=yes");
}

function email_this_page(){
	document.frm_print_email.action = "http://www.ecomputerdepot.com/index.php?main_page=email_this_page";
	//document.frm_print_email.action = "http://entell4/computerdepot/shoppingmall/index.php?main_page=email_this_page";
	document.frm_print_email.email_url.value = self.location;
	document.frm_print_email.email_title.value = document.title;
	document.frm_print_email.submit();
}

function contact_us(){
	document.frm_print_email.action = "http://www.ecomputerdepot.com/index.php?main_page=contact_us";
	//document.frm_print_email.action = "http://entell4/computerdepot/shoppingmall/index.php?main_page=contact_us";
	document.frm_print_email.email_url.value = self.location;
	document.frm_print_email.submit();
}

function show_subject(){
	//alert(document.contact_us.subject.selectedIndex);
	if(document.contact_us.subject.selectedIndex =="4"){
		document.getElementById('div_subject').style.display = 'inline';
	}
	else{
		document.getElementById('div_subject').style.display = 'none';
	}
}

function check_contact(){
	if(Trim(document.contact_us.contactname.value)=="")
	{
		alert("Please enter your name.");
		document.contact_us.contactname.focus();
		return;
	}
	else if(Trim(document.contact_us.contactemail.value)=="")
	{
		alert("Please enter your email address.");
		document.contact_us.contactemail.focus();
		return;
	}
	else if(check_email(Trim(document.contact_us.contactemail.value)))
	{
		if(document.contact_us.subject.value=="Select Subject"){
			alert("please select subject.");
			document.contact_us.subject.focus();
			return;
		}
		else if(Trim(document.contact_us.enquiry.value)==""){
			alert("please enter your message.");
			document.contact_us.enquiry.focus();
			return;
		}
		else if(Trim(document.contact_us.security_code.value)==""){
			alert("please enter security code.");
			document.contact_us.security_code.focus();
			return;
		}
		else
		{
			document.contact_us.submit();
		}
	}
}

function couponpopupWindow(url)
{
   window.open(url,"printWin", "width=770, height=500,toolbar=0, left=0,top=0, menubar=no, scrollbars=yes, resizable=yes"); 
}

function sortpage()
{
	var curr_url = location.href;
	var cut_url ='';
	var cut_url1 ='';
	var stpos = curr_url.indexOf("-o-");
	var stpos1 = curr_url.indexOf("-l-");
	if(stpos>0){
		var cut_url = curr_url.substr(0, stpos);
	}
	if(stpos1>0){
		cut_url1 = curr_url.substr(stpos1, curr_url.length);
	}

	if(cut_url!='' && cut_url1!=''){
		window.location.href = cut_url+'-o-'+document.sorter.disp_order.value+cut_url1;
	}
	else{
		var stpos = curr_url.indexOf("-c-");
		var cut_url = curr_url.substr(0, stpos);
		var cut_url1 = curr_url.substr(stpos, curr_url.length);
		window.location.href = cut_url+'-o-'+document.sorter.disp_order.value+'-l-1'+cut_url1;
	}
}


///cool popup BOF
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function hide_popup(){
	document.getElementById('overlay').style.display = 'none';
	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function show_cool_popup(file_name, screen_size){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "hidden";
	}
	var objDetails = document.getElementById('details');
	objDetails.style.visibility = 'hidden';
	

	var objOverlay = document.getElementById('overlay');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.zIndex = '99998';
	if(arrayPageSize[2]<= 999){
		objOverlay.style.width = '1016px';
	}
	else{
		if (self.innerHeight) { //others than explorer
			objOverlay.style.width = '100%';
		}
		else{
			objOverlay.style.width = arrayPageSize[2] + 'px';
		}
	}
	objOverlay.style.top = 0;
	objOverlay.style.left = 0;
	objOverlay.style.position = 'absolute';
	objOverlay.style.display = 'block';
	objOverlay.style.visibility = 'visible';
	
	var objLoadingImage = document.getElementById('loadingImage');
	objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
	objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
	objLoadingImage.style.zIndex = '99999';
	objLoadingImage.style.position = 'absolute';
	objLoadingImage.style.visibility = 'visible';
	objLoadingImage.style.display = 'block';

	Ajax_info(file_name, screen_size);
}

function visible_content(screen_size){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objLoadingImage = document.getElementById('loadingImage');
	objLoadingImage.style.visibility = 'hidden';

	var objDetails = document.getElementById('details');
	objDetails.style.zIndex = '100000';

	

	objDetails.style.top = (arrayPageScroll[1] +10)+'px';

	if(screen_size==1){
		if(screen.width<= 999){
			if (self.innerHeight) {	// all except Explorer
				objDetails.style.height = (arrayPageSize[3]-38)+'px';
			}
			else{
				objDetails.style.height = (arrayPageSize[3]-25)+'px';
			}
		}
		else{
			if (self.innerHeight) {	// all except Explorer
				objDetails.style.height = (arrayPageSize[3]-22)+'px';
			}
			else{
				objDetails.style.height = (arrayPageSize[3]-8)+'px';
			}
		}
	}

	if(arrayPageSize[2]<= 999){
		objDetails.style.width = '1015px';
	}
	else{
		if (self.innerHeight) { //others than explorer
			objDetails.style.width = '100%';
		}
		else{
			objDetails.style.width = arrayPageSize[2] + 'px';
		}
	}
	
	if(screen_size==3){//for color popup
		var cool_table = document.getElementById('cool_table');
		cool_table.style.width="320px";
	}
	else{
		var cool_table = document.getElementById('cool_table');
		cool_table.style.width="1020px";
	}

	objDetails.style.left = '0px';

	objDetails.style.display = 'block';
	objDetails.style.visibility = 'visible';

}
//cool popup EOF

//////////AJAX Info	BOF
    function Ajax_info(file_name, screen_size) {
        var httpRequest;
		if (typeof ignore_products == "undefined") {
			 ignore_products = "0";
		}		
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		
		var resoW = screen.width;
		var resoH = screen.height;
		var caller_url='';
		if(file_name.indexOf("?")>0){
			caller_url = file_name+'&h='+resoH+'&w='+resoW;
		}
		else{
			caller_url = file_name+'?h='+resoH+'&w='+resoW;
		}
		httpRequest.onreadystatechange = function() { shipping_contents(httpRequest, screen_size); };
		httpRequest.open('GET', caller_url, true);
		httpRequest.send('');
    }

    function shipping_contents(httpRequest, screen_size) {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                document.getElementById('contents').innerHTML = httpRequest.responseText;
				visible_content(screen_size);
            } else {
                document.getElementById('contents').innerHTML = 'There was a problem with the request.';
				visible_content(screen_size);
            }
        }
    }
//////AJAX Info EOF

