
//GLOBAL VARIABLES
var fname;

//BROWSERS
var recentBrowser=false; 
var isIE=false;
var isFF=false;
var isIE8=false;
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	isIE=true;
	var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ieversion>=8){isIE8=true;}
	else if (ieversion>=7){isIE7=true;}
	else if (ieversion>=6){isIE6=true;}
	else if (ieversion>=5){isIE5=true;}
}
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
	isFF=true;
	var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ffversion>=3){isFF3=true;}
	else if (ffversion>=2){isFF2=true;}
	else if (ffversion>=1){isFF1=true;}
}
if ((parseInt(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape") != -1) || ((parseInt(navigator.appVersion) >= 6 && navigator.appName.indexOf("Netscape") != -1))){
	recentBrowser=true;
}

//STYLES BROWSER ADJUSTMENT
if(!isIE || isIE8){
	document.write("<link rel='stylesheet' type='text/css' href='css/screen_mz.css' media='screen'>");
}


//FRAMES
if (window.location != top.location){top.location.href=window.location};

//DATE & TIME
var days = new Array(7);
days[1]="Sunday";days[2]="Monday";days[3]="Tuesday";days[4]="Wednesday";days[5]="Thursday";days[6]="Friday";days[7]="Saturday";
var months = new Array(12);
months[1]="Jan";months[2]="Feb";months[3]="Mar";months[4]="Apr";months[5]="May";months[6]="Jun";months[7]="Jul";months[8]="Aug";months[9]="Sep";months[10]="Oct";months[11]="Nov";months[12]="Dec";
var today = new Date();
var day = days[today.getDay() + 1]
var month = months[today.getMonth() + 1]
var date = today.getDate()
var year=today.getYear(); 
if(year<2000){year = year + 1900;}

//MENU HIGHLIGHTING
var page="";
var size="";
if(location.search!=""){
		var pairs = location.search.split("&");
		var first = pairs[0].split("=");
		page = unescape(first[1]);//page acts as cat1 value in querystring
}	

function highlightMenu(){
		if(recentBrowser){
			if (page!="" && document.getElementById(unescape(page))){
				document.getElementById(unescape(page)).className="menubtnactive";
				document.getElementById(page).childNodes[0].childNodes[0].childNodes[0].childNodes[0].className="menutextactive";
			}
		}
}
function mouseoverMenu(menuid){
	if(recentBrowser){
		if (menuid==page){
			document.getElementById(menuid).style.className="menubtnactive";
			//document.getElementById(menuid).childNodes[0].childNodes[0].childNodes[0].childNodes[0].className="menutextover";
		}else{
			if (isIE){document.getElementById(menuid).style.cursor="hand";}
			document.getElementById(menuid).className="menubtnover";
			//document.getElementById(menuid).childNodes[0].childNodes[0].childNodes[0].childNodes[0].className="menutextover";
			document.getElementById(menuid).title="Go to "+unescape(menuid.toUpperCase());
			window.status="product.php?cat1="+menuid;
			
		}
	}	
}
function mouseoutMenu(menuid){
	if(recentBrowser){
		if (menuid==page){
			document.getElementById(menuid).className="menubtnactive";
			//document.getElementById(menuid).childNodes[0].childNodes[0].childNodes[0].childNodes[0].className="menutextactive";
		}else{
			document.getElementById(menuid).className="menubtn";
			//document.getElementById(menuid).childNodes[0].childNodes[0].childNodes[0].childNodes[0].className="menutext";
		}
	}
}
function fnmenulink(menuid){
	if(recentBrowser){
		if(menuid=="design"){
			var menulink = "design.php?cat1="+escape(menuid);
		}else{
				if(menuid=="question"){
					var menulink = "question.php?cat1="+escape(menuid);
				}else{
						if(menuid=="custom"){
							var menulink = "custom.php?cat1="+escape(menuid);
						}else{
							var menulink = "cat1.php?cat1="+escape(menuid);
						}
				}
		}
		location.href= menulink;
	}
}





///////////////////////////////// NEW ///////////////////////////////////////





//BUILD EMAIL
function buildemail(emailname,emaildom){
	window.open("mailto:"+emailname+"@"+emaildom);
}


//COOKIE HANDLING
function deletecookies(){//deletes ALL cookies
	var cstring=unescape(document.cookie);
	var carray=cstring.split(";");
	for(i=0;i<carray.length;i++){
		var cpair = carray[i].split("=");
		var cname = cpair[0];
		if(i!=0){cname=cname.substring(1,cname.length);}
		setcookie(cname,"",-1);//set expiry to -1 days
	}
	history.go(0);
}
function getexpirydate(nodays){
   var UTCstring;
   Today = new Date();
   nomilli=Date.parse(Today);
   Today.setTime(nomilli+nodays*24*60*60*1000);
   UTCstring = Today.toUTCString();
   return UTCstring;
}
function getcookie(cookiename) {
   var cookiestring=""+document.cookie;
   var index1=cookiestring.indexOf(cookiename);
   if (index1==-1 || cookiename=="") return ""; 
   var index2=cookiestring.indexOf(';',index1);//stringName.indexOf(searchValue, [fromIndex])
   if (index2==-1) index2=cookiestring.length; 
   return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function setcookie(cname,value,duration){//TO DELETE A SINGLE COOKIE SEND duration VALUE -1 
  cookiestring=escape(cname)+"="+escape(value)+"; expires="+getexpirydate(duration);
  document.cookie=cookiestring;
  if(!getcookie(cname)){
  return false;
  }
  else{
   return true;
  }
}

//CURRENCY FORMATTING
function twodp(n) {
   n+=.005;
   ns = " "+n;
   ns = ns.substring(1,ns.length);
   var dp = ns.indexOf(".");
   if (dp < 0) ns = ns+".00";
   else if (dp == ns.length-2) ns = ns+"0";
   else if (dp < ns.length-1) ns = ns.substring(0,dp+3);
   return ns;
}
