<!-- //Hide script from older browsers
// Define trim function
function stringTrim() {
  return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
String.prototype.trim = stringTrim;

// Check email address
function validEmail(email) {
  invalidChars = " /:,;+=$#%&*";
  if (email == "") {
    return false;
  }
  for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i);
    if (email.indexOf(badChar,1) > -1) {
       return false;
    }
  }
  atPos = email.indexOf("@",1);
  if (atPos == -1) {
    return false;
  }
  if (email.indexOf("@",atPos+1) > -1) {
    return false;
  }
  periodPos = email.indexOf(".",atPos);
  if (periodPos == -1) {
    return false;
  }
  if (periodPos+2 > email.length) {
    return false;
  }
  return true;
}

// Validate zip code
function validZipCode(input) {
  // TODO: consider other countries
  validChars = "0123456789-";
  myLength = input.length;
  if (myLength != 5 && myLength != 9 && myLength != 10) {
    return false;
  }
  for (i=0; i<myLength; i++) {
    positionChar = input.charAt(i);
    if (validChars.indexOf(positionChar,0) < 0) {
       return false;
    }
  }
  return true;
}

// Validate phone number
function validPhone(input) {
  // TODO: consider other countries
  validChars = "0123456789- ext.()";
  myLength = input.length;
  if (myLength < 10) {
    return false;
  }  
  for (i=0; i<myLength; i++) {
    positionChar = input.charAt(i);
    if (validChars.indexOf(positionChar,0) < 0) {
       return false;
    }
  }
  return true;
}

// Smart search
function smartSearch(domain) {
  form = document.form1;
  var keyword = form.txtSearch.value;
  //keyword = keyword.replace(/\W/g, " ");
  //keyword = keyword.replace(/ +/g, " ");   
  keyword = keyword.trim();
  if(keyword != "") {
    document.location.href = domain + "search.aspx?keyword=" + escape(keyword);
  }
}

// Check keyword
function checkKeyword(domain,vthis,vevent) {
  form = document.form1;  
  if(vevent.keyCode == 13) {
    //smartSearch;
    var keyword = vthis.value;
    keyword = keyword.trim();
    if(keyword != "") {
      document.location.href = domain + "search.aspx?keyword=" + escape(keyword);
    }
    return false;
  } else {
    return true;
  }
}

// Convert invalid characters
function specialCharsConverter(inString) {
  var outString = inString;
  var charMidDot = String.fromCharCode(183);
  outString = outString.replace(/’/g, "'")
  outString = outString.replace(/–/g, "-")
  outString = outString.replace(/—/g, "-")
  outString = outString.replace(/•/g, charMidDot)
  return outString 
}

// Live chat
function openChat() {
  var theURL = "https://server.iad.liveperson.net/hc/53452500/?cmd=file&amp;file=visitorWantsToChat&amp;site=53452500&amp;referrer=" + escape(document.location);
  window.open(theURL, "Chat53452500", "width=472,height=320");
}

// Message box
function msgOKCancel(message) {
  OKOrCancel = confirm(message); 
  if (!OKOrCancel) {
    return false;
  } else {
    return true;
  }
}

//Open a intro guide window
function openWindow(url) {	
	window.open(url, '', 'width=600,height=475,resizable,scrollbars');
}

//To be compatible with the old version
function referViaEmail(ReferralSource, DesignID, ItemID) {
	window.open('ReferByEmail.aspx?ReferralSource=' + ReferralSource + '&DesignID=' + DesignID + '&ItemID=' + ItemID, '', 'width=600,height=495,resizable,scrollbars');
}

function referViaEmailForHome(ReferralSource) {
	window.open('ReferByEmail.aspx?ReferralSource=' + ReferralSource, '', 'width=600,height=495,resizable,scrollbars');
}

function referViaEmailForDesign(ReferralSource, DesignID, ItemID, ImgURL) {
	window.open('ReferByEmail.aspx?ReferralSource=' + ReferralSource + '&DesignID=' + DesignID + '&ItemID=' + ItemID + '&ImgURL=' + ImgURL, '', 'width=600,height=495,resizable,scrollbars');
}

function referViaEmailForDesignClass(ReferralSource, DesignClassID, Page, ItemID) {
	window.open('ReferByEmail.aspx?ReferralSource=' + ReferralSource + '&DesignClassID=' + DesignClassID + '&Page=' + Page + '&ItemID=' + ItemID, '', 'width=600,height=495,resizable,scrollbars');
}

function mouse_over_add_icon(DesignID) {
	var button_name = 'refer_button_' + DesignID;
	document.getElementById(button_name).src='images/icnEmailHover.gif ';	
}

function mouse_out_add_icon(DesignID) {
	var button_name = 'refer_button_' + DesignID;	
	document.getElementById(button_name).src='images/icnEmail.gif ';	
}

function openStudioAjaxLite(ItemID, DesignID, DocID, ucMatchingItemIdx, IdxType) {
	width = 800;
	switch (ItemID)	{
		//Letterhead
		case 100021:			{height=830; break}
		//Addr Label
		case 100020:			{height=400; break}
		//Mailing Label
		case 100027:			{height=450; break}
		//#10 Envelope
		case 100018:
		case 100187:			{height=500; break}
		//Business Card
		case 100001:
		case 100110:			{height=600; break}
		//Postcard
		case 100010:			{height=600; break}
		//Large Memopad
		case 100025:			{height=600; break}
		default:				{height=600; break}
	}
	var leftPos = (window.screen.width-width)/2, topPos = (window.screen.height-height)/2;	
	
	window.open('StudioAjaxLite.aspx?ucMatchingItemIdx=' + ucMatchingItemIdx + '&IdxType=' + IdxType + '&DocID=' + DocID + '&DesignID=' + DesignID + '&ItemID=' + ItemID, '', 'width=' + width +',height=' + height + ',top=' + topPos + ',left=' + leftPos +',resizable,scrollbars');	
}

function getCookie(strCookieName) {
    if (document.cookie.length>0)  {
        intStart=document.cookie.indexOf(strCookieName + "=")
        if (intStart!=-1) { 
            intStart=intStart + strCookieName.length+1 
            intEnd=document.cookie.indexOf(";",intStart)
            if (intEnd==-1) intEnd=document.cookie.length
            return unescape(document.cookie.substring(intStart,intEnd))
        } 
     }
    return ""
}

function return2BCC() {
    intCartID=getCookie('cCustomerCart')
    intCartID4BCC=getCookie('cCustomerCart4BCC')
    if ((intCartID==null || intCartID=="") && (intCartID4BCC==null || intCartID4BCC=="")) {
        alert('You need to design and approve your business card before returning to the ExchangeBusisnessCards.com')
    }
    else {
        window.location = "Return2BCC.aspx"        
    }  
}

function dc_settabactive(curtab, numtab) {        
    for (i=0; i<=numtab; i++){       
        if (i != curtab){        
            document.getElementById('dc_tab' + i).className="dc_tabinactive custom";
            document.getElementById('dc_tablink' + i).className="dc_linkinactive";            
            document.getElementById('dc_tabdetail' + i).style.display = "none";
        }
    }    
    document.getElementById('dc_tab' + curtab).className="dc_tabactive custom";   
    document.getElementById('dc_tablink' + curtab).className="dc_linkactive";    
    document.getElementById('dc_tabdetail' + curtab).style.display = "block";
}

function di_settabactive(curtab, numtab) {        
    for (i=0; i<=numtab; i++){       
        if (i != curtab){        
            document.getElementById('di_tab' + i).className="di_tabinactive custom";
            document.getElementById('di_tablink' + i).className="di_linkinactive";            
            document.getElementById('di_tabdetail' + i).style.display = "none";
        }
    }    
    document.getElementById('di_tab' + curtab).className="di_tabactive custom";   
    document.getElementById('di_tablink' + curtab).className="di_linkactive";    
    document.getElementById('di_tabdetail' + curtab).style.display = "block";
}

function setTab(tab) {
	var tablist = document.getElementById('menucontents').getElementsByTagName("ul")[0].getElementsByTagName("li");
	var contentlist = document.getElementById('innercontents').getElementsByTagName("div");
	for (var i=0, il=tablist.length; i<il; i++)	{
		if (i == tab){
			tablist[i].className="selected";
			contentlist[i].style.display = 'block';
		}else{
			tablist[i].className="";
			contentlist[i].style.display = 'none';
		}
	}
}

function setTab960(tab) {
	var tablist = document.getElementById('menucontents960').getElementsByTagName("ul")[0].getElementsByTagName("li");
	var contentlist = document.getElementById('innercontents960').getElementsByTagName("div");
	for (var i=0, il=tablist.length; i<il; i++)	{
		if (i == tab){
			tablist[i].className="selected";
			contentlist[i].style.display = 'block';
		}else{
			tablist[i].className="";
			contentlist[i].style.display = 'none';
		}
	}
}

function setCagTab(tab){
		var tablist = document.getElementById('menucontents2').getElementsByTagName("ul")[0].getElementsByTagName("li");
		var contentlist = document.getElementById('innercontents2').getElementsByTagName("div");
		for (var i=0, il=tablist.length; i<il; i++){
			if (i == tab){
				tablist[i].className="selected";
				contentlist[i].style.display = 'block';
			}else{
				tablist[i].className="";
				contentlist[i].style.display = 'none';
			}
		}
	}

//Open a learn-how window
function openPriceQuotePopup(CategoryID) {	
    if (CategoryID == 0)
        window.open('PriceQuotePopUp.aspx', '', 'width=750,height=475,resizable,scrollbars');
    else
        window.open('PriceQuotePopUp.aspx?CategoryID=' + CategoryID, '', 'width=750,height=475,resizable,scrollbars');
}

//Added by Zhonghuaqiang on 05/27/2008 : For Ajax automatic suggestions
/**
 * Provides suggestions for Ajax search.
 */
var ajaxsuggestion_j=-1;
var ajaxsuggestiontemp_str;
var $=function(node){
	return document.getElementById(node);
}
var $$=function(node){
	return document.getElementsByTagName(node);
}
function ajax_keyword(){
	var ajaxsuggestionXmlHttp;
	try{
		ajaxsuggestionXmlHttp=new XMLHttpRequest();
		}
	catch(e){
		try{
			ajaxsuggestionXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(ee){
			ajaxsuggestionXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		
		}
	ajaxsuggestionXmlHttp.onreadystatechange=function(){
	if (ajaxsuggestionXmlHttp.readyState==4){
		if (ajaxsuggestionXmlHttp.status==200){

			var data=ajaxsuggestionXmlHttp.responseText;
	
			$("Ajaxsuggest").innerHTML=data;
			//$("suggest").style.display="block"
			ajaxsuggestion_j=-1;

			}
		}
	}
	ajaxsuggestionXmlHttp.open("post", "AutoSuggest.aspx", true);
	ajaxsuggestionXmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	ajaxsuggestionXmlHttp.send("keyword="+escape($("AjaxSuggestionKeyword").value));
}
function ajaxsuggestionkeyupdeal(e){
	var keyc;
	if(window.event){
		keyc=e.keyCode;
		}
	else if(e.which){
		keyc=e.which;
		}
	if(keyc!=40 && keyc!=38){
	    ajaxsuggestiontemp_str=$("AjaxSuggestionKeyword").value;
	    if(ajaxsuggestiontemp_str.length >= 3){
	       ajax_keyword();
	    }		
		//ajaxsuggestiontemp_str=$("keyword").value;
	}
}
function ajaxsuggestionset_style(num){
	for(var i=0;i<$$("li").length;i++){
		var li_node=$$("li")[i];
		li_node.className="AjaxSuggestionLI";
	}
	if(ajaxsuggestion_j>=0 && ajaxsuggestion_j<$$("li").length){
		var i_node=$$("li")[ajaxsuggestion_j];
		$$("li")[ajaxsuggestion_j].className="AjaxSuggestionSelect";
		}
}
function ajaxsuggestion_mo(nodevalue){
	ajaxsuggestion_j=nodevalue;
	ajaxsuggestionset_style(ajaxsuggestion_j);
}
function ajaxsuggestionform_submit(){
	if(ajaxsuggestion_j>=0 && ajaxsuggestion_j<$$("li").length){
		$$("input")[0].value=$$("li")[ajaxsuggestion_j].childNodes[0].nodeValue;
		}
	document.search.submit();
}
function ajaxsuggestionhide_suggest(){		
	$("Ajaxsuggest").innerHTML=""				
	//var nodes=document.body.childNodes
	//for(var i=0;i<nodes.length;i++){
	//	if(nodes[i]!=$("keyword")){
	//		$("Ajaxsuggest").innerHTML="";
	//		}
	//	}
}
function ajaxsuggestionkeydowndeal(e){
	var keyc;
	if(window.event){
		keyc=e.keyCode;
		}
	else if(e.which){
		keyc=e.which;
		}
	if(keyc==40 || keyc==38){
	if(keyc==40){
		if(ajaxsuggestion_j<$$("li").length){
			ajaxsuggestion_j++;
			if(ajaxsuggestion_j>=$$("li").length){
				ajaxsuggestion_j=-1;
			}
		}
		if(ajaxsuggestion_j>=$$("li").length){
				ajaxsuggestion_j=-1;
			}
	}
	if(keyc==38){
		if(ajaxsuggestion_j>=0){
			ajaxsuggestion_j--;
			if(ajaxsuggestion_j<=-1){
				ajaxsuggestion_j=$$("li").length;
			}
		}
		else{
			ajaxsuggestion_j=$$("li").length-1;
		}
	}
	ajaxsuggestionset_style(ajaxsuggestion_j);
	if(ajaxsuggestion_j>=0 && ajaxsuggestion_j<$$("li").length){
		$("AjaxSuggestionKeyword").value=$$("li")[ajaxsuggestion_j].childNodes[0].nodeValue;
		}
	else{
		$("AjaxSuggestionKeyword").value=ajaxsuggestiontemp_str;
		}
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0  
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");  
    if (restore) selObj.selectedIndex=0;
}    
//End hiding script -->