function displayWindow(theURL,winName,width,height,features) 
{ //v3.1
	var window_width = width;
	var window_height = height;
	var newfeatures= features;
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;

	newWindow=window.open(''+ theURL + '',''+ winName + '','scrollbars=1, resizable=1, width=' + window_width + ', height=' + window_height + ',top=' + window_top + ',left=' + window_left + '');
	newWindow.focus();
}

function toggleDetail()
{
	var objDetail = document.getElementById("detail");
	var objToggleText = document.getElementById("toggleText");
	if(objDetail.style.display == 'none')
	{
		objDetail.style.display = 'block';		
		objToggleText.innerText = '<< click here to hide product details';
	}
	else
	{
		objDetail.style.display = 'none';
		objToggleText.innerText = 'click here to display product details >>';
	}
	
	return true;
}


function google_ad_request_done(google_ads) {
    /*
     * This function is required and is used to display
     * the ads that are returned from the JavaScript
     * request. You should modify the document.write
     * commands so that the HTML they write out fits
     * with your desired ad layout.
     */
    var s = '';
    var i;
    
    /*
     * Verify that there are actually ads to display.
     */
    if (google_ads.length == 0) {
      return;
    }

    /*
     * If an image or Flash ad is returned, display that ad.
     * Otherwise, build a string containing all of the ads and
     * then use a document.write() command to print that string.
     */

    
      s += '<div style="text-align:left;font-weight:bold;font-size:10pt">Ads by Google</div>';
      if (google_ads.length == 1) {
        /*
         * Partners should adjust text sizes
         * so ads occupy the majority of ad space.
         */
        s += '<a href="' + google_ads[0].url + '" ' +
                          'onmouseout="window.status=\'\'" ' +
                          'onmouseover="window.status=\'go to ' +
                          google_ads[0].visible_url + '\'" ' +
                          'style="text-decoration:none">' +
                          '<span style="text-decoration:underline;font-size:20pt">' +
                          '<b>' + google_ads[0].line1 + '</b><br></span>' +
                          '<span style="color:#000000;font-size:16pt">' +
                          google_ads[0].line2 + '&nbsp;' +
                          google_ads[0].line3 + '<br></span>' +
                          '<span style="color:#008000;font-size:14pt">' +
                          google_ads[0].visible_url + '</span></a><br>';
      } else if (google_ads.length > 1) {
        /*
         * For text ads, append each ad to the string.
         */
        for(i=0; i < google_ads.length; ++i) {
          s += '<br><a href="' + google_ads[i].url + '" ' +
                            'onmouseout="window.status=\'\'" ' +
                            'onmouseover="window.status=\'go to ' +
                            google_ads[i].visible_url + '\'" ' +
                            'style="text-decoration:none">' +
                            '<span style="text-decoration:underline">' +
                            '<b>' + google_ads[i].line1 + '</b><br></span>' +
                            '<span style="color:#000000">' +
                            google_ads[i].line2 + '<br>' +
                            google_ads[i].line3 + '<br></span>' +
                            '<span style="color:#008000">' +
                            google_ads[i].visible_url + '</span></a><br>';
        }
      
    }

    document.write(s);
    return;
  }

//google_hints = 'laptop notebook Dell Lenovo Toshiba Lenovo Quanta Wifi HP Compaq Acer Asus Fujitsu RAM OEM';

function rotateAds() {
    var iFrameID = '';
    var adRandom = 0;
    var src = '';
    var adWidth = '';
    var adHeight = '';
    
    var iFrames = document.getElementsByTagName('iframe');
    
    for( var index = 0; index < iFrames.length; index++ ) {
        iFrameID = iFrames[index].id;
        if( iFrameID.indexOf( 'ad_' ) >= 0 ) {
            adWidth = iFrames[index].width;
            adHeight = iFrames[index].height;

            adRandom = Math.round(Math.random() * 10000000);
            iFrameID = iFrames[index].id;
            
            if(adWidth == 336)
            {
                src = "http://ad.doubleclick.net/adi/" + adSiteValue + "/" + adZoneValue + ";tgp=" + tg_page + ";tgpi=" + tg_page_id + ";adProduct=" + adProduct + ";kw=" + adKW + ";dcopt=" + adDcopt + ";pos=0" + ";sz=" + adWidth + "x" + adHeight + ",300x250;ptile=" + adPTile-- + ";ord=" + adRandom + "?";
            }
            else
            {
                src = "http://ad.doubleclick.net/adi/" + adSiteValue + "/" + adZoneValue + ";tgp=" + tg_page + ";tgpi=" + tg_page_id + ";adProduct=" + adProduct + ";kw=" + adKW + ";dcopt=" + adDcopt + ";pos=0" + ";sz=" + adWidth + "x" + adHeight + ";ptile=" + adPTile-- + ";ord=" + adRandom + "?";
            }
            iFrames[iFrameID].src = src;
            
        }
    }
}


function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

function subscribe(email) {

    var theForm = document.forms['couponAlert'];
    
    if(echeck(email) == false)
    {
        return false;
    } else if ( theForm.chkDell.checked == false && theForm.chkHP.checked == false && theForm.chkLenovo.checked == false ) {
        alert( 'Please select a coupon to receive.' );
        return false;
    }

        var coupons = '';

        if (theForm.chkDell.checked) coupons = '1@@';
        if (theForm.chkBusinessLaptops.checked) coupons += '6@@';
        if (theForm.chkLaptopDeals.checked) coupons += '5@@';
    
    
    url = '/shared/coupons_subscribe.asp?page=' + window.location.pathname + '&email=' + email + '&coupons=' + coupons;

    
    var httpRequest;

    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;
    }
    httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
    httpRequest.open('GET', url, true);
    httpRequest.send('');
    document.forms['couponAlert'].email.disabled = true;
    document.getElementById('couponAlertMessage').innerHTML = '<b>Thanks for signing up!</b>';
}

function alertContents(httpRequest) {

    if (httpRequest.readyState == 4) {
        if (httpRequest.status == 200) {
            alert(httpRequest.responseText);
        } else {
            alert('There was a problem with the request.');
        }
    }
}