function getFreeShippingDate(){
	var dt= new Date();
	var my_month = new Array("January ", "February ", "March ", "April ", "May ", "June ", "July ", "August ", "September ", "October ", "November ", "December ");
	var my_date= dt.getDate();
	//var last_digit= my_date % 10; 
	var format;
	
	if(my_date==1 || my_date==21 || my_date==31)format="st";
	else if(my_date==2 || my_date==22)format="nd";
	else if(my_date==3 || my_date==23)format="rd";
	else format="th";
	
	my_date=my_date + format;
	document.write(my_month[dt.getMonth()] , my_date);
}// by joann

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);
	}
	x = d.getElementsByName(n);
	if(!x)
	{
		x = d.getElementById(n);
		if(!x)
		{	x = null;	}
	}
	else
	{	x = x[0];	}
	return x;
}

function MM_jumpMenu(targ,selObj,restore){
	if (!selObj.options[selObj.selectedIndex].value){
		alert('Select one please!!');
		return;
	}
	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, width, height) {
	width = width || 560;
	height = height || 550;
	bookWindow = window.open(bookgif, 'bookWin', 'width=' + width + ',height=' + height + ',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://csr.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 sendMsg2() {
	var targetUrl;
	var strUrl;
	var strTitle;
	
	strUrl = document.location.href;
	strTitle = document.title;
	targetUrl="http://csr.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="http://www.inksell.com/refillvideo.html?videoName="+strTitle
    window.open(targetUrl,"WndBroadCastView","statusbar=no,scrollbars=no,status=yes,resizable=no,width=460,height=540");
}

function broadcast_old(strTitle, strBitRate) {
	var targetUrl;	

	targetUrl="http://video.inksell.net/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;'
    }
}
function emailCheck(str)
{
	var at = "@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);
	
	if (str.indexOf(at)==-1) { return false;}
	if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {	return false;	}
	if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr)	{ return false;	}
	if (str.indexOf(at, (lat+1)) != -1)	{ return false;	}
	if (str.substring(lat-1, lat) == dot || str.substring(lat + 1, lat + 2) == dot)	{ return false;	}
	if (str.indexOf(dot, (lat + 2)) == -1)	{ return false;	}	
	if (str.indexOf(" ") != -1)	{ return false;	}

	return true;
}
