//var hostName = 'http://site.i-techcompany.com/';
(document.location.toString().indexOf('norder.html')!=-1)?document.location='http://order.store.yahoo.com/cgi-bin/wg-order?wintech':'';

var moretxtvalue='';
var nRec = 0;
var related = new Array();
var CurrItemId='addcook';
var ie = false;
var ns6 = false;
var ns = false;
var opera = false;



if (eval(document.layers)) { ns=true; }
else {
    if (eval(document.all)) { ie=true; if (navigator.userAgent.indexOf('Opera')!=-1) opera=true;}
        else {
            if (eval(document.getElementById)) { ns6=true;}
            }
    }

function checkSearch(obj) {
  if (!obj.changed  || obj.value == '') {
    alert('Enter search keywords!');
    return false;
  }
  return true;
}

/////////////////
// Flying Order
////////////////
function init_fly() {
	x_cl_body = window.document.body.clientWidth;
	y_cl_body = window.document.body.clientHeight/2;
	scrollw=0;
	(x_cl_body > 900)?(scrollw=window.document.body.scrollLeft):(scrollw=scrollw-window.document.body.scrollLeft);
	new_x=x_cl_body;
	x=new_x-170-scrollw;
	y=window.document.body.scrollTop + y_cl_body - 55;
	fly_obj = Layer('flying_order');
	fly_obj.style.display = '';
	fly_obj.style.left = x;
	fly_obj.style.top = y;
}	

////////////////////////
// DHTML Menu functions
///////////////////////
var ns4=document.layers;
var ns6=document.getElementById&&(!document.all);
var ie4=document.all;
var opr=navigator.userAgent.indexOf("Opera");

function GetObj(Id) {
   return (document.getElementById)?document.getElementById(Id):(document.all?document.all[Id]:eval(Id));
}

function DL_fGetRealLeft(oElement)
{
   var nXPos = oElement.offsetLeft;
    var oParentEl = oElement.offsetParent;  
    while (oParentEl.tagName != "DIV")
    {
        nXPos += oParentEl.offsetLeft;
        oParentEl = oParentEl.offsetParent;
    }
    return nXPos+14;

}


function DL_fGetRealTop(oElement)
{
    var nYPos = oElement.offsetTop;
    var oParentEl = oElement.offsetParent;  
    while (oParentEl.tagName != "DIV")
    {
        nYPos += oParentEl.offsetTop;
        oParentEl = oParentEl.offsetParent;
    }
    return nYPos-6;
}

function DL_fPositionLayer(elem,menu)
{
	imageElem = GetObj('img_'+elem);
    menu.style.left = DL_fGetRealLeft(imageElem) + "px";
    menu.style.top = DL_fGetRealTop(imageElem) + "px";
}

function fadeMenu(oId) {
	menu = GetObj(oId);
	if (ns4) {
		menu.visibility="hide";
	} else {
		menu.style.visibility = "hidden";
	}
}

function showSubMenu(oId,level) {
    menu = GetObj('submenu_'+oId);
	
	clearTimeout(menu.fade);
	menu.fade = null;
	if (level != 1) 
		DL_fPositionLayer(oId,menu);
    st = (ns6||ie4) ? menu.style : menu;
	st.visibility="visible";
}

function hideSubMenu(oId) {
	menu = GetObj('submenu_'+oId);
	clearTimeout(menu.fade);
	menu.fade = setTimeout("fadeMenu('submenu_"+oId+"')", 50);
}

function mout(id,level) {
	id.style.backgroundColor = (level % 2 == 0)?("#D9D9DD"):("#E0E0E4");
}

function mover(id,level,oId) {
	id.style.backgroundColor = (level % 2 == 0)?("#E0E0E4"):("#D9D9DD");
}

function set_table_class(oId, level) {
	table = GetObj('table_'+oId+'_'+level);
	mod = (level % 2 == 0)?('2'):('1');
	table.className = 'sublev'+mod;
}
///////////////////////////////////////////////

//////////////////////
// Tabs functions
//////////////////////
function activatePage(page) {
	for (i in ShowMas) 
		if (ShowMas[i] == page) {
			activePage = page; 
			break; 
		}
	if (activePage == 0) {
		activePage = ShowMas[0];
	}
	SetCookie('prodTabNo',activePage);
	for (i in ShowMas) {
		if (Layer('mia_'+ShowMas[i])) Layer('mia_'+ShowMas[i]).style.display = 'none';
		if (Layer('mi_'+ShowMas[i])) Layer('mi_'+ShowMas[i]).style.display = 'none';
		if (Layer('mis_'+ShowMas[i])) Layer('mis_'+ShowMas[i]).style.display = 'none';
		if (Layer('ProdTabBlock'+ShowMas[i]))
			Layer('ProdTabBlock'+ShowMas[i]).style.display = (ShowMas[i] == activePage) ? '':'none';
		
	}
	for (tpage in ShowMas) {
		if (activePage==ShowMas[tpage]) {
			if (Layer('mia_'+ShowMas[tpage])) Layer('mia_'+ShowMas[tpage]).style.display = '';
			if (Layer('mis_'+ShowMas[tpage-1])) Layer('mis_'+ShowMas[tpage-1]).style.display = 'none';
		} else {
			if (Layer('mi_'+ShowMas[tpage])) Layer('mi_'+ShowMas[tpage]).style.display = '';
			if (Layer('mis_'+ShowMas[tpage])) Layer('mis_'+ShowMas[tpage]).style.display = '';
		}
	}
}
////////////////////////
function Layer(layerName) {
return (ns)?(document.layers[layerName]):((ns6)?(document.getElementById(layerName)):(document.all(layerName)));
}
function enlarge(url,imgw,imgh) {
var leftPos = (screen.availWidth-900) / 2;
var topPos = (screen.availHeight-600) / 2;
imgw=eval(imgw)+20;
imgh=eval(imgh)+30;
window.open(url, 'EnlargePicture','width='+imgw+',height='+imgh+',scrollbars=no,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}

function insertMore() {
if (moretxtvalue!='') {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open('more_info.html', 'EnlargePicture','width=600,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
    MoreInfo.document.write('<html><head><title>I-TechCompany.com - Product more info</title><link rel="stylesheet" href="/main.css" type="text/css" title="main style sheet"></head><body bgcolor="#ffffff" marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"><center><table border="0" cellpadding="0" cellspacing="0" width="100%" height="478"><tr valign="top"><td width="7" nowrap="" background="/images/b-left-bg.gif"><img src="/images/pix.gif" width="1" height="1"/></td><td width="100%"><div align="center"><img src="/images/popup-logo.gif" border="0" vspace="10" hspace="10"/></div><div style="border-bottom:1px solid #BBBBBB;"></div><table border="0" cellpadding="0" cellspacing="6" width="100%"><tr><td><table border="0" cellpadding="5" cellspacing="0"><tr><td height="390" valign="top">'+moretxtvalue+'</td></tr></table></td></tr></table></td><td width="7" nowrap="" background="/images/b-right-bg.gif"><img src="/images/pix.gif" width="1" height="1"/></td></tr></table><div style="border-bottom:1px solid #BBBBBB;"></div><div align="right"><font size=1 face="Arial" color="#cccccc">Design and System Improvements by <a href="http://www.ystoredesign.com" target="_blank"><font size=1 face="Arial" color="#cccccc">Y!StoreDesign Studio</font></a></font>&nbsp;&nbsp;</div><div style="background: url(/images/bg-i-topline.gif); height:6px"><img src="/images/pix.gif"/></div></center></body></html>');
    }
else {
    alert('Your browser settings not allow to run scripts or version of your browser is old.');
    }
}


var Currtop='<div class="pad4"></div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%" colspan="3" style="border-left:1px solid #cacacc;border-top:1px solid #cacacc;border-right:1px solid #cacacc"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#e0e0e4" width="100%"><tr><td width="12" bgcolor="#EC7F27"><img src="http://site.i-techcompany.com/images/pix.gif" border="0" width="12" height="1"/></td><td class="pad7"><h1 class="name">Currently viewed items</h1></td></tr></table></td></tr><tr><td colspan="3" style="padding:10px;border-left:1px solid #cacacc;border-right:1px solid #cacacc"><table border="0" cellpadding="0" cellspacing="0"><tr valign="top">';
var Currbot='</tr></table></td></tr><tr height="10"><td width="10" nowrap="" style="border-left: solid 1px #CACACC;border-bottom: solid 1px #CACACC;"><img src="http://site.i-techcompany.com/images/pix.gif" width="1" height="1" border="0" alt=""/></td><td width="100%" style="border-bottom: solid 1px #CACACC;"><img src="http://site.i-techcompany.com/images/pix.gif" width="1" height="1" border="0" alt=""/></td><td width="10" nowrap=""><img src="http://site.i-techcompany.com/images/prod-corn.gif" width="10" height="10" border="0" alt=""/></td></tr></table><div class="pad5"></div>';

var Currdiv='<td width="15"><img src="http://site.i-techcompany.com/images/pix.gif" border="0" width="10" height="1"/></td>';

var CurrItema='<td width="80" align="center"><table border="0" cellpadding="0" cellspacing="0" width="65" height="63" class="bord"><tr><td align="center" valign="middle">';
var CurrItemb='</td>';

    function pasteRelated(items) {
	var items_count=items?items:5;
    var asd=0;
    var Rell=false;
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            Rell=true;
            asd=asd+1;
            }
        }
//  alert(GetCookie('rel_5'));
    if (Rell) {
        document.write(Currtop);
    for (var i=1;i<(items_count+1);i++) {
        ccc='rel_'+i;
        if (GetCookie(ccc)) {
            tempvall=GetCookie(ccc);
            document.write(CurrItema);
            document.write(tempvall);
            document.write(CurrItemb);
            /*if (i!=items_count) {
                document.write(Currdiv);
                }*/
            }
        }
        document.write(Currbot);
        }
    } 

function addtorel(items) {
	var items_count=items?items:5;
    related[CurrItemId]=CurrItem;
    for (var i=1;i<items_count+1;i++) {
    cc='rel_'+i;
    if (!GetCookie(cc)) {
        SetCookie(cc, related[CurrItemId]);
        break;
        }
    else {
            if (GetCookie(cc)==related[CurrItemId]) {
            break;
            }
            else {
            if (GetCookie('MaxItem')) {
                gg=true;
                for (var i=1;i<items_count+1;i++) {
                tt='rel_'+i;
                if (GetCookie(tt)==related[CurrItemId]) {
                    gg=false;
                    }
                }
                if (gg) {
                mm=GetCookie('MaxItem');
                kk='rel_'+mm;
                SetCookie(kk, related[CurrItemId]);
                if (eval(mm)!=items_count) {
                    mm=eval(mm)+1;
                    }
                    else {
                    mm=eval(mm);
                    mm=1;
                    }
                SetCookie('MaxItem', mm);
                break;
                }
                }
            }
        }
    if (i==5 && !GetCookie('MaxItem')) {
        SetCookie('MaxItem', 1);
        }
    }
}    
	
function TellToFriend() {
var NewPop = new Object();
NewPop=window.open("/custom/ytellafriend.php?link="+pid.toLowerCase(),"tellafriend","HEIGHT=345,WIDTH=520,scrollbars=yes,resizable=yes,top=50,left=50");
NewPop.window.focus();
}
function PriceRequest() {
var NewPop = new Object();
NewPop=window.open("/custom/pricerequest.php?link="+pid.toLowerCase(),"pricerequest","HEIGHT=280,WIDTH=520,scrollbars=yes,resizable=yes,top=50,left=50");
NewPop.window.focus();
}

function maillist(emailval) {
var NewPop = new Object();
NewPop=window.open('/custom/addemail.php?mail='+emailval,'popupemail','HEIGHT=165,WIDTH=520,scrollbars=yes,resizable=yes,top=50,left=50');
NewPop.window.focus();
}

function makeavailable(num,state) {
    obj=eval("document.forms.multiorder.vwquantity"+num)
    obj.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))
    obj2=eval("document.forms.multiorder.vwitem"+num)
    obj2.disabled=!state;
    ((state)?(obj.value=1):(obj.value=0))
	
}

function chprice(pr,num) {
var obj2;
if (eval("document.forms.multiorder.pricetxt"+num)) {
		obj=eval("document.forms.multiorder.pricetxt"+num);
		if (eval(document.forms.multiorder2)) {obj2=eval("document.forms.multiorder2.toppricetxt"+num);} else {obj2=false;}
		obj3=eval("document.forms.multiorder.flypricetxt"+num);
		pr=Math.round(pr*100)/100;
		if (pr.toString().indexOf('.')!=-1) {
			pr=pr.toString().substring(0,pr.toString().indexOf('.')+3);
			if (pr.toString().split('.')[1].length==1) pr=pr+'0';
		}else{
			pr=pr+'.00';
		}
		obj.value='$'+pr;
		if (obj2) obj2.value='$'+pr;
		obj3.value='$'+pr;
	}
}

function calcoptions(num) {
var optval=0;
len=eval("optionvalue"+num+".length");
for (i=1;i<len;i++) {
optcheck=eval("optionvalue"+num+"[i]");
if (optcheck.indexOf('+$')!=-1) {
    optval=optval+eval(optcheck.split('(+$')[1].split(')')[0]);
    }
    else {
        if (optcheck.indexOf('-$')!=-1) {
            optval=optval+eval('-'+optcheck.split('(-$')[1].split(')')[0]);
            }
            else {
            optval=optval+0;
            }
    }
}
return eval(optval);
}

function updateall(num) {
var totalprice;
calcq(num);
((eval("optionvalue"+num).length>0)?(totalprice=eval("qtyvalue"+num)*(eval("ipr"+num)+calcoptions(num))):(totalprice=eval("qtyvalue"+num)*eval("ipr"+num)));
chprice(totalprice,num);
}

function calcq(num) {
obj=eval("ranges"+num);
for (var i in obj) {
    q=eval("qtyvalue"+num);
    ((obj[i]['q']<=q)?(eval("ipr"+num+"=obj[i]['pr']")):(''))
    }
} 


function PasteComments() {
document.write('<img src="/img/t-pixel.gif" width="10" height="9"><br><table cellpadding=0 cellspacing=0 border=0 width="603" background="/img/t5a4.gif"><tr><td class="boldthfix2" height="20"><div class="marg6">Customer Reviews</div><img src="/img/t-pixel.gif" width="1" height="2"><br></td></tr></table><img src="/img/t-pixel.gif" width="19" height="13" alt="" border="0"><br><table border="0" cellpadding="0" cellspacing="0" width="500"><tr><td width="500">')
for (var i=0; i<mesRecords.length;i++) {
    if (mesRecords[i].indexOf('|')!=-1) {
        tempval=mesRecords[i].split('|');
        document.write('<table cellpadding=0 cellspacing=0 border=0 width="100%"><tr><td valign="top" bgcolor="#B5B4B4"><table cellpadding=0 cellspacing=1 border=0 width="100%"><tr bgcolor="#ffffff"><td class="smallthfix4" width="173"><img src="/img/t-pixel.gif" width="30%" height="3" alt="" border="0"><br><div class="marg3"><nobr><span class="hboldthfix"><b>'+tempval[1]+'</b></span> ('+tempval[0]+')<br></nobr></div><img src="/img/t-pixel.gif" width="1" height="2" alt="" border="0"><br></td><td align="right" width="70%"><img src="/custom/img/stars'+tempval[3]+'0.gif" width="55" height="13" alt="" border="0" hspace="7"><br></td></tr><tr bgcolor="#ffffff"><td class="smallfix" colspan="2"><img src="/img/t-pixel.gif" width="1" height="3" alt="" border="0"><br><div class="marg0">'+tempval[2]+'</div><img src="/img/t-pixel.gif" width="1" height="3" alt="" border="0"><br></td></tr></table></td></tr></table><img src="/img/t-pixel.gif" width="1" height="16" alt="" border="0"><br>');
        }
    }
document.write('</td></tr></table>');
}
            function checkfileds(obj) {
            var msg='';
            ((obj.username.value=='')?(msg+='Pelease enter your name.\n'):(''));
            ((obj.vote.value==-1)?(msg+='Pelease select rating.\n'):(''));
            ((obj.message.value=='')?(msg+='Pelease enter message.\n'):(''));
            ((msg=='')?(obj.submit()):(alert(msg)))
            }

function openImages(ind) {
	currentimg = ind ? ind : 0;
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    //MoreInfo = window.open( 'images.html', 'EnlargePicture','width=600,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
    MoreInfo = window.open( 'gallery.html', 'EnlargePicture','width=600,height=640,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
//  MoreInfo.preloadimg(images);
}
function openVideos(num) {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open( 'videos.html?video='+num, 'EnlargePicture','width=600,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}
function openShipping(num) {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open( 'shipping-calc.html', 'EnlargePicture','width=600,height=500,scrollbars=yes,resizable=yes,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}
function openDelivery(num) {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open( 'delivery-est.html', 'EnlargePicture','width=1000,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}
function openFreight(num) {
    var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
    var MoreInfo = new Object();
    MoreInfo = window.open( 'freight.html', 'EnlargePicture','width=600,height=500,scrollbars=yes,resizable=no,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}

function retriveimages(arrname) {
return eval(arrname);
}


function PasteItem(num) {
var expdate = new Date (); 
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
cookievar='rotator'+num;
Items=eval('Items'+num);
if (!GetCookie(cookievar)) {
    SetCookie(cookievar, 1, expdate);
    }
if (!GetCookie(cookievar)) {
    cur=Math.round(Math.random()*(Items.length-1));
    }
    else {
    cur=eval(GetCookie(cookievar));
    }


if (Items[cur]) {
    document.write(Items[cur]);
    cur=cur+1;
    SetCookie(cookievar, cur, expdate);
    }
    else {
        if (Items[1]) {
        document.write(Items[1]);
        SetCookie(cookievar, 2, expdate);
        }
    }
}

function submitProduct() {
	if (Layer('optionsListSrc')) Layer('optionsListDst').innerHTML = Layer('optionsListSrc').innerHTML;
	return false;
}

function openPopup(url){
	var leftPos = (screen.availWidth-900) / 2;
    var topPos = (screen.availHeight-600) / 2;
	window.open(url, "MoreInfo", 'width=600,height=500,scrollbars=yes,resizable=yes,statusbar=no,location=no,titlebar=0,top=' + topPos + ',left=' + leftPos);
}

