function gotourl() {
	url = "http://www.inksell.com/" + document.frmPrinterSearch.selectPrinterSearch.value;
	
	if ( url != "" )
		document.location.href = url;
}

function MM_findObj(n, d) {
	var p,i,x; 

	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n]; 
	
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];

	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_jumpMenu(targ,selObj,restore){
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){
	var selObj = MM_findObj(selName); 
	
	if (selObj) MM_jumpMenu(targ,selObj,restore);
}


function newWindow(bookgif) {
	bookWindow = window.open(bookgif, 'bookWin', 'width=700,height=500,scrollbars=yes');
	bookWindow.focus();
}

function newWindow2(bookgif2) {
	bookWindow = window.open(bookgif2, 'bookWin2', 'width=500,height=300,scrollbars=yes');
	bookWindow.focus();
}

function sendMsg() {
	var targetUrl;
	var strUrl;
	var strTitle;
	
	strUrl = document.location.href;
	strTitle = document.title;
	targetUrl="http://www.inksell.net/inkemail/sendemail.asp?hdnUrl="+strUrl+"&hdnTitle="+strTitle;
	window.open(targetUrl,"WndNoticeView","statusbar=no,scrollbars=yes,status=yes,resizable=no,width=460,height=570");
}

function addFavorites() {
	window.external.AddFavorite(location.href, document.title);
}
function broadcast( strTitle, strBitRate ) {
	var targetUrl;	

	targetUrl="http://66.118.2.103/inkbroad/broadcast.asp?hdnTitle="+strTitle+"&hdnBitRate="+strBitRate;
	
	if ( strBitRate == "250" )
		window.open(targetUrl,"WndBroadCastView","statusbar=no,scrollbars=no,status=yes,resizable=no,width=460,height=540");
	else if ( strBitRate == "100" )
		window.open(targetUrl,"WndBroadCastView","statusbar=no,scrollbars=no,status=yes,resizable=no,width=460,height=445");
	else
		window.open(targetUrl,"WndBroadCastView","statusbar=no,scrollbars=no,status=yes,resizable=no,width=460,height=470");
}

function getQueryVariable(variable) 
{
  	var query = window.location.search.substring(1);
  	var vars = query.split("&");
  	for (var i=0;i<vars.length;i++) 
	{
    		var pair = vars[i].split("=");
    		if (pair[0] == variable) 
		{
      			return pair[1];
    		}
  	} 
}

function getQueryValue()
{
	var hn = window.location.hostname;
	var checksub = window.location.search.substring(1);
	var sid = getQueryVariable("sourceid");
	
	var aid = getQueryVariable("siteid");
	
	var pid = getQueryVariable("pageid");
    var skey = getQueryVariable("skey");
	
	if (hn == 'www.inksell.com')
	{
		if (checksub != '')
		{
			var imgUrl ='<img src=http://66.118.2.101/tracking/trackimage.jpg?' + checksub + '>';
			//var imgUrl ='<img src=http://inksell.brinkster.net/data/inksellTrackIm.jpg?' + checksub + '>';
			document.write(imgUrl);

			if (sid == null)
			{		
				//document.write(checksub);
				setCookie('bfreesidink',checksub,'','');
			}
			else
			{
				//document.write(sid + ' ' + pid);
				sid += "&siteid=" + aid;
				setCookie('bfreesidink',sid,'','');
				if (pid == 'formsearch')
				{          	
					strUrl = 'http://search.store.yahoo.com/cgi-bin/nsearch?follow-pro=1&vwcatalog=goinksell&catalog=goinksell&query=' + skey + '&Submit=search';
					redir(strUrl);
				}
			}
		}
		//else document.write("no paramter");	
	}
	//else document.write("hn is not inksell.com");
	
}

function redir(strUrl)
{
	window.location.href=strUrl;	
}

function setCookie(cookieName, cookieValue, cookiePath, cookieExpires) 
{ 
	cookieValue = escape(cookieValue); 
	if (cookieExpires == "") 
	{ 
		var nowDate = new Date(); 
		nowDate.setTime(nowDate.getTime()+3600000*24*1);
		//nowDate.setMonth(nowDate.getMonth() + 6); l
		cookieExpires = nowDate.toGMTString(); 
	} 
	if (cookiePath != "") 
	{ 
		cookiePath = ";Path=" + cookiePath; 
	} 
	document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires; 
}
function toggleFold(id, objid)
{
    atag = document.getElementById(objid)
    target = document.getElementById(id)
    if (target.className == 'fold')
    {
        target.className = 'unfold';
        target.style.cssText += ';display:block;'
        atag.style.cssText += ';display:none;'
    }
    else
    {
        target.className = 'fold';
        target.style.cssText += ';display:none;'
        atag.style.cssText += ';display:block;'
    }
}
