﻿
// cmajorossy 12.01.2007 :: function ToolTip for error handeling
//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.
// cmajorossy 11.20.2007 :: function swapBackround for imageGallery created
// cmajorossy 11.14.2007 :: add ajax control for htnl requestrs

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number

}

function searchreviews(qstring) {
window.location='/review/advsearch.aspx?t=' + encodeURIComponent(qstring);
}

function searchgoogle(qstring) {
// window.location='/search-results.aspx?q=' + encodeURIComponent(qstring) + '&cx=011239505048760151329:xzunat5ag7y&cof=FORID%3a11';
window.location='http://www.laptopmag.com/search-results.aspx?q=' + encodeURIComponent(qstring) + '&cx=011239505048760151329%3axtwjxuvb8mo&cof=FORID%3a11';
}

function checkEnter(e,fn,passedvar){ 
var characterCode;
if (e && e.which){ 
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else {
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if (characterCode == 13) { 
fn(passedvar);
return false;
}
else {
return true;
}

}

function cbusterlink(url) {
var rnd = (Math.round((9999999999-1000000000) * Math.random() + 1000000000));
var code = '<A HREF="' + url.replace('[CACHEBUSTER]',rnd) + '" target="_blank">';
document.write(code);
}
function cbusterimg(url) {
var rnd = (Math.round((9999999999-1000000000) * Math.random() + 1000000000));
var code = '<IMG SRC="' + url.replace('[CACHEBUSTER]',rnd) + '" border="0">';
document.write(code);
}

function hideAdvSearch() {
 if (ieversion<7) {
 document.getElementById("advsearchd").style.display = 'none';
 /*
document.getElementById("prodcat").style.display = 'none';
document.getElementById("prodsubcat").style.display = 'none';
*/
	}
}
function showAdvSearch() {
 if (ieversion<7) {
  document.getElementById("advsearchd").style.display = 'block';
/*
document.getElementById("prodcat").style.display = 'block';
document.getElementById("prodsubcat").style.display = 'block';
*/
}
}


function clearCtrl(obj)
{
    //alert(document.getElementById(obj).value);
    document.getElementById(obj).value = '';
}
function showCtrl(obj)
{
    //alert(document.getElementById(obj).value);
    document.getElementById(obj).style.display = 'block';
}
function hideCtrl(obj)
{
    //alert(document.getElementById(obj).value);
    document.getElementById(obj).style.display = 'none';
}

//Main Feature functions
function setSelectedMFTab(obj)
{
    document.getElementById('ctl00_ContentPlaceHolder1_MainFeature1_hlTab1').className = "";
    document.getElementById('ctl00_ContentPlaceHolder1_MainFeature1_hlTab2').className = "";
    document.getElementById('ctl00_ContentPlaceHolder1_MainFeature1_hlTab3').className = "";
    document.getElementById('ctl00_ContentPlaceHolder1_MainFeature1_hlTab4').className = "";
    document.getElementById(obj).className = "selected";
}

function hideAllMFContent()
{
    hideCtrl('mfContent1');
    hideCtrl('mfContent2');
    hideCtrl('mfContent3');
    hideCtrl('mfContent4');
}

function showMFTab(tab)
{
   var divContent = 'mfContent' + tab;
   var tabObj = 'ctl00_ContentPlaceHolder1_MainFeature1_hlTab' + tab; 
   //alert(divContent);alert(tabObj);
   hideAllMFContent();
   showCtrl(divContent);
   setSelectedMFTab(tabObj);
}

var tab = 1;
var t;

function rotateMF()
{
    if(tab==5){tab=1;}
    //alert(tab);
    showMFTab(tab);
    t=setTimeout("rotateMF()",6000);
    tab++;
}

function stopRotate()
{
    clearTimeout(t);
}

    



// cmajorossy 11.14.2007 :: add ajax control for htnl requestrs
function ajaxFunction(requestPage, divElement){
	var ajaxRequest;  
	// Browser Support Code
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			document.getElementById(divElement).innerHTML = ajaxRequest.responseText;
		}						
	}
	ajaxRequest.open("GET", requestPage, true);
	ajaxRequest.send(null); 
}


function ajaxFunction_JSON(requestPage, divElement){
	var ajaxRequest;  
	// Browser Support Code
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			var JSON = eval('(' + ajaxRequest.responseText + ')'); 
			document.getElementById(divElement).innerHTML = JSON.HTML;
			eval(JSON.JS);	
		}						
	}
	ajaxRequest.open("GET", requestPage, true);
	ajaxRequest.send(null); 
}

function trackclick(d, r, n) {
	if (n === undefined) {
	n = '';
	}
    if(document.images){
        (new Image()).src="http://www.laptopmag.com/feeds/ct.php?r="+r+
        "&d="+d+"&n="+n;
    }
    return true;
}

function trackrevshop(d, r) {
var n = 'pg_revpull';
if (d.substr(0,17) == '/review/shop.aspx') {
	    if(document.images){
        (new Image()).src="http://www.laptopmag.com/feeds/ct.php?r="+r+
        "&d="+d+"&n="+n;
		}
	}
window.location=d;
}


// cmajorossy 11.20.2007 :: function swapBackround for imageGallery created
function swapBackround(elementFill, imageSource)
{
    document.getElementById(elementFill).style.backgroundImage = "url('"+imageSource+"')";
}

function openWin(URL) {
trackclick(URL,window.location,'print');
location.href = URL;
}


var table_tabs = new Array();
table_tabs[0] = "topics";
table_tabs[1] = "products";
table_tabs[2] = "posts";
function HideContent(d) {
document.getElementById("pagenav_" + d).style.display = "none";
}
function ShowContent(d) {
document.getElementById("pagenav_" + d).style.display = "block";
document.getElementById("td_" + d + "_active").style.display = "block";
document.getElementById("td_" + d + "_hidden").style.display = "none";
document.getElementById("td_" + d).className = "active_tab";

for (var i=0, len=table_tabs.length; i<len; ++i ){
	if (table_tabs[i] != d) {
	document.getElementById("pagenav_" + table_tabs[i]).style.display = "none";
	document.getElementById("td_" + table_tabs[i] + "_active").style.display = "none";
	document.getElementById("td_" + table_tabs[i] + "_hidden").style.display = "block";
	document.getElementById("td_" + table_tabs[i]).className = "inactive_tab";
	}
}
	
}




