var globalVarDebug = false; //changes different javascript functions for debugging or not

function loadFunctions(){
	//all onload functions
	//replaceMissingImages();	
}

function pageSize(objName){
	try{
		var screenSize = readCookie("screenSize");
		if (screenSize == null)
			screenSize = 0;
		screenSize = parseInt(screenSize);			
		var jsScreenSize = screen.width;			
		var css1024 = "/v2/css/1024.css";
		var css800 = "/v2/css/800.css";
		var cssObj =document.getElementById(objName);
		if (screenSize.toString() != jsScreenSize.toString() || (jsScreenSize < 1024) ){
			screenSize = jsScreenSize;
			createCookie("screenSize",jsScreenSize,1)
			if (screenSize >=1024){
				cssObj.href = css1024;
				//alert("resized to 1024");
			}
			else{
				cssObj.href = css800;
				//alert("resized to 800");
			}
				
		}
	}
	catch(e){
		errorCatch(e);
	}
	

}

function createCookie(name,value,days) {
	try{
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}
	catch(e){
		errorCatch(e);
	}
}

function readCookie(name) {
	try{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	catch(e){
		errorCatch(e);
	}
}

function eraseCookie(name) {
	try{
		createCookie(name,"",-1);
	}
	catch(e){
		errorCatch(e);
	}
}
function clearDefault(el,e2) {
	try{
		if (el.defaultValue==el.value) el.value = "";
		
		if(e2!=null)
			e2.style.visibility='visible';
	}
	catch(e){
		errorCatch(e);
	}
}

function restoreDefault(el, elValue, e2) {
	try{
		if (el.value=="") el.value = elValue;
		
		if(e2!=null && el.value != elValue)
			e2.style.visibility='visible';
		else if(e2!=null)
			e2.style.visibility='hidden';
	}
	catch(e){
		errorCatch(e);
	}
}
function bookmark(){

	var url = document.location.href;
	var title = "ZENMED Skin Care Products";
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
function swapProductsMenu(menuItem1, menuItem2){
	try{
		if (menuItem1 !="")
			toggleSlide(menuItem1);
		if (menuItem2 !="")	
			toggleSlide(menuItem2);
	}
	catch(e){
		errorCatch(e);
	}
}

function toggleDisplay(objName) {
	try{
		if (document.getElementById(objName).style.display=="none") {
			document.getElementById(objName).style.display = "block";
		}
		else
		{
			document.getElementById(objName).style.display = "none";
		}
		}
	catch(e){
		errorCatch(e);
	}
}
function makeorder(objName){
	try{
		var orderBoxObj = document.getElementById(objName);
		var orderLink = "https://secure.zenmed.com/checkout.cgi/buynow/?id="+orderBoxObj.value;
		window.location.href=orderLink;
	}
	catch(e){
		errorCatch(e);
	}
}

function showGuarantee(){
	try{
		CreatePopup('myemail','/popUpPages/Guarantee.aspx','Product Guarantee',607,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}

function showShipping(){
	try{
		CreatePopup('myemail','/popupPages/shippingOptions.aspx','Shipping options',610,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}

function showSecure(){
	try{
		CreatePopup('myemail','/popUpPages/safeShopping.aspx','Secure Shopping',500,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function showPaymentMethods(){
	try{
		CreatePopup('myemail','/popuppages/paymentMethods.aspx','Payment Options',600,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}


function showBBB(){
	try{
		CreatePopup('BBB Window', '//www.bbbonline.org/cks.asp?id=1050407145021','ZENMED Member of BBB',600,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function showSavings(productID){
	try{
		window.location.href="/products/productdetails.aspx?id="+productID+"#orderoptions";
	}
	catch(e){
		errorCatch(e);
	}
}
function submitTestimonial(){
	try{
		CreatePopup('Testimonial Window', '/popupPages/submitTestimonial.aspx','Tell us your success story.',610,500,'#ffffff','visible');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}


function showLargerProduct(productID){
	try{
		CreatePopup('myemail','/popupPages/largerImage.aspx?id='+productID,'Larger Image',510,510,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function showMailList(){
	try{
		CreatePopup('myemail','/popupPages/maillist.aspx?page='+document.location.href,'Join the ZENMED Mailing List',600,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}

function joinMailList(name, email, list){
	try{
		if (name.length < 1 || name=="Name"){
			alert("Your name is not correct\r\nPlease correct it before signing up.");
			return false;
		}
		if (!checkEmailAddress(email)){
			alert("Your email address is not correct\r\nPlease correct it before signing up.");
			return false;
		}
		var hostUrl = "http://"+location.hostname;
		var refererURL = window.document.location.href;
		var successURL = hostUrl+"/popuppages/newsletter.aspx?mail=1";
		var failureURL = hostUrl+"/popuppages/newsletter.aspx?mail=0";
		var popUpURL = 'http://action.clickkingdom.com/mailman.aspx?name='+name+'&email='+email+'&list='+list+'&mode=add&referer='+escape(refererURL)+'&success='+escape(successURL)+'&failure='+escape(failureURL);
		CreatePopup('myemail',popUpURL,'Mailing Lists',600,368,'#ffffff','visible');
	}
	catch(e){
		errorCatch(e);
	}
}
function removeMailList(email){
	try{
		if (!checkEmailAddress(email)){
			alert("Your email address is not correct\r\nPlease correct it before signing up.");
			return false;
		}
		var successURL = "http://dev.zenmed.com/popuppages/newsletter.aspx?removeEmail=1";
		var failureURL = "http://dev.zenmed.com/popuppages/newsletter.aspx?removeEmail=0";
		var popUpURL = 'http://action.clickkingdom.com/mailman.aspx?email='+email+'&mode=del&success='+successURL+'&failure='+failureURL;
		CreatePopup('myemail',popUpURL,'Mailing Lists',600,500,'#ffffff','visible');
	}
	catch(e){
		errorCatch(e);
	}
}
function showIngredients(porductID){
	try{
		CreatePopup('','/popupPages/ingredients.aspx?id='+porductID,'Ingredients List',600,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function trackOrder(){
	try{
		var orderID = document.getElementById('orderTrackingOrderId').value;
		var emailAddress = document.getElementById('orderTrackingEmailAddress').value;
		alert("Order Tracking is Under Construction");
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
	
function popMore(porductID){
	try{
		CreatePopup('moreInfo','','Product Information',500,400,'#ffffff','hidden', 200,200);
	}
	catch(e){
		errorCatch(e);
	}

}
function showLayer(divID, width, height){
	try{
		CreatePopup(divID,'','',width,height,'#ffffff','hidden');
	}
	catch(e){
		errorCatch(e);
	}
}
function showAsSeenIn(){
	try{
		CreatePopup('asSeenIn','/popupPages/asSeenIn.aspx','ZENMED As Seen In',350,350,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
	
}
function showWhyZenmed(){
	try{
		CreatePopup('whyZenmed','/popupPages/whyZenmed.aspx','Why Choose ZENMED Skin Care Products',600,400,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}


function showPhoneOrder(){
	try{
		CreatePopup('phoneOrder','/popupPages/PhoneOrder.aspx','Order ZENMED on the Phone',600,350,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function showCallBack(){
	try{
		CreatePopup('CallBack','http://ep.estara.com/Email2.jsp?accountid=200106282650&template=58339&authorizeurl=http://www.realping.com/accts/authorize_test.cfm?id=16963&var1=16963&var2=1000&var3=1000&var4=1&var5=test&postcall_url=http://www.realping.com/accts/postcall.cfm?id=16963','We will call you for FREE',450,390,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}

function showPaypal(){
	try{
		CreatePopup('paypal','https://www.paypal.com/row/cgi-bin/webscr?cmd=xpt/cps/popup/OLCWhatIsPayPal-outside','Order ZENMED With Paypal',400,350,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}	
}
function showSaveOrder(){
	try{
		CreatePopup('saveOrder','/popupPages/saveOrder.aspx','Save your order for later',350,350,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}
}
function sendToFriend(){
	try{
		var referringPage = window.document.location.href;
		CreatePopup('saveOrder','/popupPages/sendToAfriend.aspx?page='+referringPage,'Send this page to a friend',600,450,'#ffffff','hidden');
		return false;
	}
	catch(e){
		errorCatch(e);
	}	
}
function hideLayer(){
	try{
		killPopup();
	}
	catch(e){
		errorCatch(e);
	}	
}
function WipeClean(obj) {
	try{
   		obj.value = "";
	}
	catch(e){
		errorCatch(e);
	}	
}

function BlankEntry(formVal,obj) {
	try{	
		if (obj.value == "") {
			obj.value = formVal;
		}
	}
	catch(e){
		errorCatch(e);
	}
}
//search box function area
var SearchButtonShowing = false;
var SearchAreaShowing = false;
function trySearch(){
	try{
		var searchBox = document.getElementById('searchBox');
		if (searchBox.value.length >=1 & searchBox.value !="Search" ){
			if (!SearchButtonShowing){
				//searchButton
				searchButton("create");
				//searchArea("create");
				SearchButtonShowing = true
			}
		}
		else{
			searchButton("kill");
			//searchArea("kill");
			SearchButtonShowing = false;
		}
	}
	catch(e){
		errorCatch(e);
	}	
		
}
function addSearchButton(searchBoxObjName){
	//try{
	//	var searchForm = document.getElementById(searchBoxObjName);
		//	var button = document.createElement("img");
			//button.setAttribute("src", "/images/icons/clickToSearch.gif");
		//	button.setAttribute("width", "88");
		//	button.setAttribute("height", "14");
		//	button.setAttribute("border", "0");
		//	button.style.position = "absolute";
		//	button.style.zindex = "5";
		//	button.style.top = searchForm.offsetTop;
		//	button.style.left = searchForm.offsetLeft;
		//	button.setAttribute("id", "searchButton");
		//	document.body.appendChild(button);
		//}
		//else{
			//var button = document.getElementById("searchButton");
			//searchForm.removeChild(button);
		//}			
	//}
	//catch(e){
	//	errorCatch(e);
	//}	
}
function searchArea(action){
	try{
		var searchDiv = document.getElementById('search');
		if (action=="create"){
			var image = document.createElement("img");
			image.setAttribute("src", "/v2/images/menu/searchCover.png");
			image.setAttribute("width", "160");
			image.setAttribute("height", "25");
			image.className= "searchArea";
			image.setAttribute("id", "searchArea");
			searchDiv.appendChild(image);
			var searchText = document.createElement("A");
			searchText.setAttribute("href", "javascript:doSearch();");
			searchText.setAttribute("id", "searchText");
			searchText.innerHTML = "Search now";
			
			searchText.className = "searchText";
			searchDiv.appendChild(searchText);
			var clearSearchText = document.createElement("A");
			clearSearchText.setAttribute("HREF", "javascript:clearSearch();");
			clearSearchText.innerHTML = "clear";
			clearSearchText.className = "clearSearchText";
			searchDiv.appendChild(clearSearchText);
		}
		else{
			var image = document.getElementById("searchArea");
			searchDiv.removeChild(image);
		}	
	}
	catch(e){
		errorCatch(e);
	}	
	
}
function clearSearch(){
	try{
		searchBox = document.getElementById('searchBox')	
		searchBox.value = "Search";
		searchBox.blur();
	}
	catch(e){
		errorCatch(e);
	}	
}
function doSearch(queryboxObjName){
	try{
		var searchBox, searchAddress;
		searchAddress = "/search?cx=008956118202896145067:4jgfxetuqby&cof=FORID:11&ie=UTF-8&sa=Search";
		searchBox = document.getElementById(queryboxObjName);
		//alert(queryboxObjName);
		//alert(searchBox);
		window.location.href=searchAddress+'&q='+searchBox.value;
	}
	catch(e){
		errorCatch(e);
	}	

}

function switchRosaceaProduct(stType){
	try{
		var featureDry, featureDryButton, featureOily, orderBoxDry, orderBoxOily;
		featureDry = document.getElementById('rosaceaDrySkinFeature');
		featureDryButton = document.getElementById('featureProdViewDrySkin');
		featureOily = document.getElementById('rosaceaOilySkinFeature');
		featureOilyButton = document.getElementById('featureProdViewOilySkin');
		//orderBoxDry = document.getElementById('');
		//orderBoxOily = document.getElementById('');
		if (stType == 'oily'){
			featureDry.className = "hidden";
			featureOily.className = "shown";
			featureDryButton.src = "/images/box/fp_ViewDry_on.gif";
			featureOilyButton.src  = "/images/box/fp_ViewOily.gif";
		}
		else{
			featureDry.className = "shown";
			featureOily.className = "hidden";
			featureDryButton.src = "/images/box/fp_ViewDry.gif";
			featureOilyButton.src  = "/images/box/fp_ViewOily_on.gif";
		}
	}
	catch(e){
		errorCatch(e);
	}	
}

function checkEmailAddress_bad(mailids){
	try{
		var arr = new Array('.com','.net','.org','.biz','.coop','.info','.museum','.name','.pro'
		,'.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag','.ai','.al',
		'.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw','.az','.ba','.bb',
		'.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm','.bn','.bo','.br','.bs',
		'.bt','.bv','.bw','.by','.bz','.ca','.cc','.cd','.cf','.cg','.ch','.ci',
		'.ck','.cl','.cm','.cn','.co','.cr','.cu','.cv','.cx','.cy','.cz','.de',
		'.dj','.dk','.dm','.do','.dz','.ec','.ee','.eg','.eh','.er','.es','.et',
		'.fi','.fj','.fk','.fm','.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh',
		'.gi','.gl','.gm','.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy',
		'.hk','.hm','.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io',
		'.iq','.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
		'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li','.lk',
		'.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg','.mh','.mk',
		'.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt','.mu','.mv','.mw',
		'.mx','.my','.mz','.na','.nc','.ne','.nf','.ng','.ni','.nl','.no','.np',
		'.nr','.nu','.nz','.om','.pa','.pe','.pf','.pg','.ph','.pk','.pl','.pm',
		'.pn','.pr','.ps','.pt','.pw','.py','.qa','.re','.ro','.rw','.ru','.sa',
		'.sb','.sc','.sd','.se','.sg','.sh','.si','.sj','.sk','.sl','.sm','.sn',
		'.so','.sr','.st','.sv','.sy','.sz','.tc','.td','.tf','.tg','.th','.tj',
		'.tk','.tm','.tn','.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug',
		'.uk','.um','.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu',
		'.ws','.wf','.ye','.yt','.yu','.za','.zm','.zw');
		
		var mai = mailids;
		var val = true;
		var beforeat="";
		var afterat="";
		var afterat2="";
		
		var dot=mai.lastIndexOf(".");
		var con=mai.substring(dot, mai.length);
		con=con.toLowerCase();
		con=con.toString();
		
		for(var i=0;i<(arr.length);i++)
		{
			if(con == arr[i])
			{
				val=true;
				break;
			}
			else
			{
				val=false;
			}
		}
		
		var att=mai.lastIndexOf("@");
		beforeat=mai.substring(0,att);
		beforeat=beforeat.toLowerCase();
		beforeat=beforeat.toString();
		var asci1=beforeat.charCodeAt(0);
		
		afterat=mai.substring(att+1, dot);
		afterat=afterat.toLowerCase();
		afterat=afterat.toString();
		
		afterat2=mai.substring(att+1, mai.length);
		afterat2=afterat2.toLowerCase();
		afterat2=afterat2.toString();
		
		if(beforeat=="" || afterat=="" || beforeat.length>30)
			val=false;
		
		if(afterat2.length>64 || afterat.length<2)
			val=false;
		
		if((afterat.charCodeAt(0))==45 || (afterat.charCodeAt(afterat.length-1))==45)
			val=false;
		
		if(val==true)
		{
			if(asci1 > 47 && asci1 < 58)
				val=false;
				
			if(asci1 < 48 || asci1 > 57)
			{
				for(var i=0; i<=beforeat.length-1; i++)
				{
					var asci2=beforeat.charCodeAt(i);
					if((asci2<=44 || asci2==47) || (asci2>=58 && asci2<=94) || (asci2==96) || (asci2>=123 && asci2<=127))
					{
						val=false;
						break;
					}
				}
				
				for(var j=0; j<=afterat.length-1; j++)
				{
					var asci3=afterat.charCodeAt(j);
					if((asci3<=44) || (asci3==46) || (asci3==47) || (asci3>=58 && asci3<=96) || (asci3>=123 && asci3<=127))
					{
						val=false;
						break;
					}
				}	
			}
		}
		
		if(val==false)
		{
			//alert("Your maild "+mai+" is not valid");
			return false;
		}
		else
		{
			return true;
		}
	}
	catch(e){
		errorCatch(e);
	}	
}

function checkEmailAddress(src){
	try{
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(src);
	}
	catch(e){
		errorCatch(e);
	}	
}

	
function stopEnter (e){
	try{
		if(!e) e=window.event;
		key = e.keyCode ? e.keyCode : e.which;
		
		if(key==13)
			return false;
	}
	catch(e){
		errorCatch(e);
	}	
}

function errorCatch(errorObj){
	//try{ //only enable once js is solid

	if (!globalVarDebug){
		//production
		var errorReportURL ="http://ragingcreations.com/errorHandle.php?error="+errorObj.message+"&sourceOfError="+errorObj.constructor+"&lineNbr="+errorObj.lineNumber+"&jsFileName="+errorObj.fileName+"&page="+document.location.href.toString()+"&ErrorType=JavaScript";
		if (typeof(document.body) =="object"){
			//page is already loaded
			var errorImg = document.createElement('img');
			errorImg.setAttribute("src", errorReportURL);
			errorImg.setAttribute("width", "1");
			errorImg.setAttribute("hight", "1");
			document.body.appendChild(errorImg);
		}
		else{
			//body not loaded js error onloading etc..
			document.writeln("<img src='"+errorReportURL+"' width='1' height='1' border='0'>");
		}
	}
	else{	
		//debug mode
		alert("JavaScript Error")
		document.writeln("Error is: "+errorObj.message+"  Page:"+document.location.href.toString());
		//}
	}
	//catch(e){
	//}
	return true;
}
function uncoughtErrorCatch(){
	try{ //only enable once js is solid

		if (!globalVarDebug){
			//production
			var errorReportURL ="http://ragingcreations.com/errorHandle.php?error=UnCoughtJsError&page="+document.location.href.toString()+"&ErrorType=JavaScrript";
			if (typeof(document.body) =="object"){
				//page is already loaded
				var errorImg = document.createElement('img');
				errorImg.setAttribute("src", errorReportURL);
				errorImg.setAttribute("width", "1");
				errorImg.setAttribute("hight", "1");
				document.body.appendChild(errorImg);
			}
			else{
				//body not loaded js error onloading etc..
				document.writeln("<img src='"+errorReportURL+"' width='1' height='1' border='0'>");
			}
		}
		else{	
			//debug mode
			alert("JavaScript Error")
			document.writeln("Error is: "+errorObj.message+"  Page:"+document.location.href.toString());
		}
	}
	catch(e){
	}
	return true;
}



function log404(){
	if (!globalVarDebug){
		//production
		var errorReportURL ="http://ragingcreations.com/errorHandle.php?error=404Error-referringPage-"+document.referrer+"&page="+document.location.href.toString()+"&ErrorType=404";
		//if (typeof(document.body) =="object"){
			//page is already loaded
			//var errorImg = document.createElement('img');
			//errorImg.setAttribute("src", errorReportURL);
			//errorImg.setAttribute("width", "1");
			//errorImg.setAttribute("hight", "1");
			//document.body.appendChild(errorImg);
		//}
		//else{
			//body not loaded js error onloading etc..
			document.writeln("<img src='"+errorReportURL+"' width='1' height='1' border='0'>");
		//}
	}
	else{	
		//debug mode
		alert("404 Error")
		//}
	}	
}

function testImage(img) {
  var complete = img.complete;
  var ret = null; // Return value
  // Workaround for Safari -- it only supports the 
  // complete attrib on script-created images
  if (typeof complete == 'undefined') {
    var test = new Image();
    // If the original image was successfully loaded,
    // src for new one should be pulled from cache
    test.src = img.src;
    complete = test.complete;
  }   
  // Check the complete attrib. Use strict equality
  // check -- don't want undefined, null, etc.
  // --------------------------
  // False -- Img failed to load in IE/Safari, or is
  // still trying to load in FF
  if (complete === false) {
    ret = false;
  }   
  // True, but image has no size -- image failed to
  // load in FF
  else if (complete === true &&
    img.naturalWidth == 0) {
    ret = false;
  }   
  // Otherwise all we can do is assume image loaded
  else {
    ret = true;
  }   
  return ret;
}



function logMissingImage(imgSrc){
	if (!globalVarDebug){
		//production
		var errorReportURL ="http://ragingcreations.com/errorHandle.php?error=404Error-referringPage-"+document.referrer+"&page="+document.location.href.toString()+"&ErrorType=MissingImage&imgSrc="+imgSrc;
		//if (typeof(document.body) =="object"){
			//page is already loaded
			//var errorImg = document.createElement('img');
			//errorImg.setAttribute("src", errorReportURL);
			//errorImg.setAttribute("width", "1");
			//errorImg.setAttribute("hight", "1");
			//document.body.appendChild(errorImg);
		//}
		//else{
			//body not loaded js error onloading etc..
			document.writeln("<img src='"+errorReportURL+"' width='1' height='1' border='0'>");
		//}
	}
	else{	
		//debug mode
		alert("404 Error")
		//}
	}	
}
function replaceMissingImages(){
  for (var i=0; i<document.images.length; i++){
    img = new Image();
    img.src = document.images[i].src;
    if (!testImage(img))
	//alert("replace");
	  logMissingImage(document.images[i].src);
      //document.images[i].src = '/images/noImage.gif';

  }
}


function showDisplay(elName) {
	if (document.getElementById(elName).style.display=="none") {
		document.getElementById(elName).style.display = "block";
	}
}

function hideDisplay(elName) {
	if (document.getElementById(elName).style.display=="block") {
		document.getElementById(elName).style.display = "none";
	}
}

function toggleShowHideDisplay(elNameShow,elNameHide) {
	if (document.getElementById(elNameHide).style.display=="block") {
		showDisplay(elNameShow);
		hideDisplay(elNameHide);
	}
}

// JavaScript Document

function CreatePopup(divID,htmlpage,title,width,height,divBackGroundColourHexCode,isShow,locationX,locationY){
var winType = 'iframe';
if (htmlpage ==''){
	winType = 'div';
	htmlpage = divID;
}


if(locationX==null)
	dhtmlWindow=dhtmlmodal.open('dhtmlWindow', winType, htmlpage , title, 'width='+width+'px,height='+height+'px,center=1,resize=0,scrolling=1',divBackGroundColourHexCode,isShow)
else
	dhtmlWindow=dhtmlmodal.open('dhtmlWindow', winType, htmlpage , title, 'width='+width+'px,height='+height+'px,left='+locationX+',top='+locationY+',resize=0,scrolling=1',divBackGroundColourHexCode,isShow)

  

} 


function killPopup(){
	dhtmlmodal.close(dhtmlWindow);
}





// -------------------------------------------------------------------
// DHTML Window Widget- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 15th, 07'
// v1.01: Feb 21th, 07' (see changelog.txt)
// v1.02: March 26th, 07' (see changelog.txt)
// v1.03: May 5th, 07' (see changelog.txt)
// v1.1:  Oct 29th, 07' (see changelog.txt)
// -------------------------------------------------------------------

var dhtmlwindow={
imagefiles:['/widgets/popUpWindow/windowstyle/min.gif', '/widgets/popUpWindow/windowstyle/window_close.png', '/widgets/popUpWindow/windowstyle/restore.gif', '/widgets/popUpWindow/windowstyle/resize.gif'], //Path to 4 images used by script, in that order
ajaxbustcache: true, //Bust caching when fetching a file via Ajax?
ajaxloadinghtml: '<b>Loading Page. Please wait...</b>', //HTML to show while window fetches Ajax Content?

minimizeorder: 0,
zIndexvalue:100,
tobjects: [], //object to contain references to dhtml window divs, for cleanup purposes
lastactivet: {}, //reference to last active DHTML window

init:function(t){
	var domwindow=document.createElement("div") //create dhtml window div
	domwindow.id=t
	domwindow.className="dhtmlwindow"
	var domwindowdata=''
	domwindowdata='<div class="drag-handle"><div class="box_win_tl"><div class="box_win_tr"><div class="box_win_t"><div id="dhtmlTitle" class="DhtmlTitleStyle">DHTML Window</div> '

	domwindowdata+='<div class="drag-controls"><img src="'+this.imagefiles[0]+'" title="Minimize" /><img src="'+this.imagefiles[1]+'" width="21" height="21" title="Close"/></div></div></div></div>'
	domwindowdata+='</div>'
	domwindowdata+='<div class="drag-contentarea"></div>'
	domwindowdata+='<div class="drag-statusarea"><input name="Close" type="button"  title="Close Window" value="  Close  " onclick="killPopup();" /><div class="drag-resizearea" style="background: transparent url("'+this.imagefiles[3]+') top right no-repeat;"> </div></div>'
	domwindowdata+='</div>'

	domwindow.innerHTML=domwindowdata
	document.getElementById("dhtmlwindowholder").appendChild(domwindow)
	//this.zIndexvalue=(this.zIndexvalue)? this.zIndexvalue+1 : 100 //z-index value for DHTML window: starts at 0, increments whenever a window has focus
	var t = document.getElementById(t);
	var divs=t.getElementsByTagName("div")
	for (var i=0; i<divs.length; i++){ //go through divs inside dhtml window and extract all those with class="drag-" prefix
		if (/drag-/.test(divs[i].className))
			t[divs[i].className.replace(/drag-/, "")]=divs[i] //take out the "drag-" prefix for shorter access by name
	}
	//t.style.zIndex=this.zIndexvalue //set z-index of this dhtml window
	t.handle._parent=t //store back reference to dhtml window
	t.resizearea._parent=t //same
	t.controls._parent=t //same
	t.onclose=function(){return true} //custom event handler "onclose"
	t.onmousedown=function(){dhtmlwindow.setfocus(this)} //Increase z-index of window when focus is on it
	t.handle.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on handle div
	t.resizearea.onmousedown=dhtmlwindow.setupdrag //set up drag behavior when mouse down on resize div
	t.controls.onclick=dhtmlwindow.enablecontrols
	t.show=function(){dhtmlwindow.show(this)} //public function for showing dhtml window
	t.hide=function(){dhtmlwindow.hide(this)} //public function for hiding dhtml window
	t.close=function(){dhtmlwindow.close(this)} //public function for closing dhtml window (also empties DHTML window content)
	t.setSize=function(w, h){dhtmlwindow.setSize(this, w, h)} //public function for setting window dimensions
	t.moveTo=function(x, y){dhtmlwindow.moveTo(this, x, y)} //public function for moving dhtml window (relative to viewpoint)
	t.isResize=function(bol){dhtmlwindow.isResize(this, bol)} //public function for specifying if window is resizable
	t.isScrolling=function(bol){dhtmlwindow.isScrolling(this, bol)} //public function for specifying if window content contains scrollbars
	t.load=function(contenttype, contentsource, title){dhtmlwindow.load(this, contenttype, contentsource, title)} //public function for loading content into window
	this.tobjects[this.tobjects.length]=t
	return t //return reference to dhtml window div
},

open:function(t, contenttype, contentsource, title, attr, recalonload){
	var d=dhtmlwindow //reference dhtml window object
	function getValue(Name){
		var config=new RegExp(Name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
		return (config.test(attr))? parseInt(RegExp.$1) : 0 //return value portion (int), or 0 (false) if none found
	}
	if (document.getElementById(t)==null) //if window doesn't exist yet, create it
		t=this.init(t) //return reference to dhtml window div
	else
		t=document.getElementById(t)
	this.setfocus(t)
	t.setSize(getValue(("width")), (getValue("height"))) //Set dimensions of window
	
	
	//var xpos=getValue("locationX")//Get x coord of window
	//var ypos=getValue("locationY")//Get y coord of window
	//alert(xpos)
	
	var xpos=getValue("center")? "middle" : getValue("left") //Get x coord of window
	var ypos=getValue("center")? "middle" : getValue("top") //Get y coord of window
	
	//t.moveTo(xpos, ypos) //Position window
	if (typeof recalonload!="undefined" && recalonload=="recal" && this.scroll_top==0){ //reposition window when page fully loads with updated window viewpoints?
		if (window.attachEvent && !window.opera) //In IE, add another 400 milisecs on page load (viewpoint properties may return 0 b4 then)
			this.addEvent(window, function(){setTimeout(function(){t.moveTo(xpos, ypos)}, 400)}, "load")
		else
			this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "load")
	}
	t.isResize(getValue("resize")) //Set whether window is resizable
	t.isScrolling(getValue("scrolling")) //Set whether window should contain scrollbars
	t.style.visibility="visible"
	t.style.display="block"
	t.contentarea.style.display="block"
	t.moveTo(xpos, ypos) //Position window
	t.load(contenttype, contentsource, title)
	if (t.state=="minimized" && t.controls.firstChild.title=="Restore"){ //If window exists and is currently minimized?
		t.controls.firstChild.setAttribute("src", dhtmlwindow.imagefiles[0]) //Change "restore" icon within window interface to "minimize" icon
		t.controls.firstChild.setAttribute("title", "Minimize")
		t.state="fullview" //indicate the state of the window as being "fullview"
	}
	return t
},

setSize:function(t, w, h){ //set window size (min is 150px wide by 100px tall)
	t.style.width=Math.max(parseInt(w), 150)+"px"
	t.contentarea.style.height=Math.max(parseInt(h), 100)+"px"
},

moveTo:function(t, x, y){ //move window. Position includes current viewpoint of document
	this.getviewpoint() //Get current viewpoint numbers
	t.style.left=(x=="middle")? this.scroll_left+(this.docwidth-t.offsetWidth)/2+"px" : this.scroll_left+parseInt(x)+"px"
	t.style.top=(y=="middle")? this.scroll_top+(this.docheight-t.offsetHeight)/2+"px" : this.scroll_top+parseInt(y)+"px"
},

isResize:function(t, bol){ //show or hide resize inteface (part of the status bar)
	//t.statusarea.style.display=(bol)? "block" : "none"
	//t.resizeBool=(bol)? 1 : 0
},

isScrolling:function(t, bol){ //set whether loaded content contains scrollbars
	t.contentarea.style.overflow=(bol)? "auto" : "hidden"
},

load:function(t, contenttype, contentsource, title){ //loads content into window plus set its title (3 content types: "inline", "iframe", or "ajax")
	if (t.isClosed){
		alert("DHTML Window has been closed, so no window to load contents into. Open/Create the window again.")
		return
	}
	var contenttype=contenttype.toLowerCase() //convert string to lower case
	if (typeof title!="undefined")
		document.getElementById('dhtmlTitle').innerHTML = title;
		//t.handle.innerHTML = t.handle.innerHTML.replace('DHTML Window',title);
	if (contenttype=="inline")
		t.contentarea.innerHTML=contentsource
	else if (contenttype=="div"){

		var inlinedivref=document.getElementById(contentsource)
		t.contentarea.innerHTML=(inlinedivref.defaultHTML || inlinedivref.innerHTML) //Populate window with contents of inline div on page
		if (!inlinedivref.defaultHTML)
			inlinedivref.defaultHTML=inlinedivref.innerHTML //save HTML within inline DIV
		inlinedivref.innerHTML="" //then, remove HTML within inline DIV (to prevent duplicate IDs, NAME attributes etc in contents of DHTML window
		inlinedivref.style.display="none" //hide that div
	}
	else if (contenttype=="iframe"){
		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
		if (!t.contentarea.firstChild || t.contentarea.firstChild.tagName!="IFRAME") //If iframe tag doesn't exist already, create it first
			t.contentarea.innerHTML='<iframe src="" style="margin:0; padding:0; width:100%; height: 100%" name="_iframe-'+t.id+'"></iframe>'
		window.frames["_iframe-"+t.id].location.replace(contentsource) //set location of iframe window to specified URL
		}
	else if (contenttype=="ajax"){
		this.ajax_connect(contentsource, t) //populate window with external contents fetched via Ajax
	}
	t.contentarea.datatype=contenttype //store contenttype of current window for future reference
},

setupdrag:function(e){
	var d=dhtmlwindow //reference dhtml window object
	var t=this._parent //reference dhtml window div
	d.etarget=this //remember div mouse is currently held down on ("handle" or "resize" div)
	var e=window.event || e
	d.initmousex=e.clientX //store x position of mouse onmousedown
	d.initmousey=e.clientY
	d.initx=parseInt(t.offsetLeft) //store offset x of window div onmousedown
	d.inity=parseInt(t.offsetTop)
	d.width=parseInt(t.offsetWidth) //store width of window div
	d.contentheight=parseInt(t.contentarea.offsetHeight) //store height of window div's content div
	if (t.contentarea.datatype=="iframe"){ //if content of this window div is "iframe"
		t.style.backgroundColor="#ffffff"   ///"#F8F8F8" //colorize and hide content div (while window is being dragged)
		t.contentarea.style.visibility="hidden"
	}
	document.onmousemove=d.getdistance //get distance travelled by mouse as it moves
	document.onmouseup=function(){
		if (t.contentarea.datatype=="iframe"){ //restore color and visibility of content div onmouseup
			t.contentarea.style.backgroundColor="white"
			t.contentarea.style.visibility="visible"
		}
		d.stop()
	}
	return false
},

getdistance:function(e){
	var d=dhtmlwindow
	var etarget=d.etarget
	var e=window.event || e
	d.distancex=e.clientX-d.initmousex //horizontal distance travelled relative to starting point
	d.distancey=e.clientY-d.initmousey
	if (etarget.className=="drag-handle") //if target element is "handle" div
		d.move(etarget._parent, e)
	else if (etarget.className=="drag-resizearea") //if target element is "resize" div
		d.resize(etarget._parent, e)
	return false //cancel default dragging behavior
},

getviewpoint:function(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
},

rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
	this.getviewpoint() //Get current window viewpoint numbers
	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
},

move:function(t, e){
	t.style.left=dhtmlwindow.distancex+dhtmlwindow.initx+"px"
	t.style.top=dhtmlwindow.distancey+dhtmlwindow.inity+"px"
},

resize:function(t, e){
	t.style.width=Math.max(dhtmlwindow.width+dhtmlwindow.distancex, 150)+"px"
	t.contentarea.style.height=Math.max(dhtmlwindow.contentheight+dhtmlwindow.distancey, 100)+"px"
},

enablecontrols:function(e){
	var d=dhtmlwindow
	var sourceobj=window.event? window.event.srcElement : e.target //Get element within "handle" div mouse is currently on (the controls)
	if (/Minimize/i.test(sourceobj.getAttribute("title"))) //if this is the "minimize" control
		d.minimize(sourceobj, this._parent)
	else if (/Restore/i.test(sourceobj.getAttribute("title"))) //if this is the "restore" control
		d.restore(sourceobj, this._parent)
	else if (/Close/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)
	else if (/Close_Window/i.test(sourceobj.getAttribute("title"))) //if this is the "close" control
		d.close(this._parent)	
	return false
},

minimize:function(button, t){
	dhtmlwindow.rememberattrs(t)
	button.setAttribute("src", dhtmlwindow.imagefiles[2])
	button.setAttribute("title", "Restore")
	t.state="minimized" //indicate the state of the window as being "minimized"
	t.contentarea.style.display="none"
	t.statusarea.style.display="none"
	if (typeof t.minimizeorder=="undefined"){ //stack order of minmized window on screen relative to any other minimized windows
		dhtmlwindow.minimizeorder++ //increment order
		t.minimizeorder=dhtmlwindow.minimizeorder
	}
	t.style.left="10px" //left coord of minmized window
	t.style.width="200px"
	var windowspacing=t.minimizeorder*10 //spacing (gap) between each minmized window(s)
	t.style.top=dhtmlwindow.scroll_top+dhtmlwindow.docheight-(t.handle.offsetHeight*t.minimizeorder)-windowspacing+"px"
},

restore:function(button, t){
	dhtmlwindow.getviewpoint()
	button.setAttribute("src", dhtmlwindow.imagefiles[0])
	button.setAttribute("title", "Minimize")
	t.state="fullview" //indicate the state of the window as being "fullview"
	t.style.display="block"
	t.contentarea.style.display="block"
	if (t.resizeBool) //if this window is resizable, enable the resize icon
		t.statusarea.style.display="block"
	t.style.left=parseInt(t.lastx)+dhtmlwindow.scroll_left+"px" //position window to last known x coord just before minimizing
	t.style.top=parseInt(t.lasty)+dhtmlwindow.scroll_top+"px"
	t.style.width=parseInt(t.lastwidth)+"px"
},


close:function(t){
	try{
		var closewinbol=t.onclose()
	}
	catch(err){ //In non IE browsers, all errors are caught, so just run the below
		var closewinbol=true
 }
	finally{ //In IE, not all errors are caught, so check if variable isn't defined in IE in those cases
		if (typeof closewinbol=="undefined"){
			alert("An error has occured somwhere inside your \"onclose\" event handler")
			var closewinbol=true
		}
	}
	if (closewinbol){ //if custom event handler function returns true
		if (t.state!="minimized") //if this window isn't currently minimized
			dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
		if (window.frames["_iframe-"+t.id]) //if this is an IFRAME DHTML window
			window.frames["_iframe-"+t.id].location.replace("about:blank")
		else
			t.contentarea.innerHTML=""
		t.style.display="none"
		t.isClosed=true //tell script this window is closed (for detection in t.show())
	}
	return closewinbol
},


setopacity:function(targetobject, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between)
	if (!targetobject)
		return
	if (targetobject.filters && targetobject.filters[0]){ //IE syntax
		if (typeof targetobject.filters[0].opacity=="number") //IE6
			targetobject.filters[0].opacity=value*100
		else //IE 5.5
			targetobject.style.filter="alpha(opacity="+value*100+")"
		}
	else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
		targetobject.style.MozOpacity=value
	else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
		targetobject.style.opacity=value
},

setfocus:function(t){ //Sets focus to the currently active window
	this.zIndexvalue++
	t.style.zIndex=this.zIndexvalue
	t.isClosed=false //tell script this window isn't closed (for detection in t.show())
	this.setopacity(this.lastactivet.handle, 0.5) //unfocus last active window
	this.setopacity(t.handle, 1) //focus currently active window
	this.lastactivet=t //remember last active window
},


show:function(t){
	if (t.isClosed){
		alert("DHTML Window has been closed, so nothing to show. Open/Create the window again.")
		return
	}
	if (t.lastx) //If there exists previously stored information such as last x position on window attributes (meaning it's been minimized or closed)
		dhtmlwindow.restore(t.controls.firstChild, t) //restore the window using that info
	else
		t.style.display="block"
	this.setfocus(t)
	t.state="fullview" //indicate the state of the window as being "fullview"
},

hide:function(t){
	t.style.display="none"
},

ajax_connect:function(url, t){
	var page_request = false
	var bustcacheparameter=""
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
		}
	}
	else
		return false
	t.contentarea.innerHTML=this.ajaxloadinghtml
	page_request.onreadystatechange=function(){dhtmlwindow.ajax_loadpage(page_request, t)}
	if (this.ajaxbustcache) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
	return true;
},

ajax_loadpage:function(page_request, t){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	t.contentarea.innerHTML=page_request.responseText
	}
},


stop:function(){
	dhtmlwindow.etarget=null //clean up
	document.onmousemove=null
	document.onmouseup=null
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
},

cleanup:function(){
	for (var i=0; i<dhtmlwindow.tobjects.length; i++){
		dhtmlwindow.tobjects[i].handle._parent=dhtmlwindow.tobjects[i].resizearea._parent=dhtmlwindow.tobjects[i].controls._parent=null
	}
	window.onload=null
}

} //End dhtmlwindow object

document.write('<div id="dhtmlwindowholder"><span style="display:none">.</span></div>') //container that holds all dhtml window divs on page
window.onunload=dhtmlwindow.cleanup











// -------------------------------------------------------------------
// DHTML Modal window- By Dynamic Drive, available at: http://www.dynamicdrive.com
// v1.0: Script created Feb 27th, 07'
// v1.01 May 5th, 07' Minor change to modal window positioning behavior (not a bug fix)
// REQUIRES: DHTML Window Widget (v1.01 or higher): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/
// -------------------------------------------------------------------

if (typeof dhtmlwindow=="undefined")
alert('ERROR: Modal Window script requires all files from "DHTML Window widget" in order to work!')

var dhtmlmodal={
veilstack: 0,
open:function(t, contenttype, contentsource, title, attr,backcolor,isShow,recalonload){
	
	var d=dhtmlwindow //reference dhtmlwindow object
	this.interVeil=document.getElementById("interVeil") //Reference "veil" div
	this.veilstack++ //var to keep track of how many modal windows are open right now
	this.loadveil(backcolor,isShow)
	if (typeof recalonload!="undefined" && recalonload=="recal" && d.scroll_top==0)
		d.addEvent(window, function(){dhtmlmodal.loadveil()}, "load")
		var t=d.open(t, contenttype, contentsource, title, attr, recalonload)
	t.controls.firstChild.style.display="none" //Disable "minimize" button
	t.controls.onclick=function(){dhtmlmodal.forceclose(this._parent)} //OVERWRITE default control action with new one
	t.show=function(){dhtmlmodal.show(this)} //OVERWRITE default t.show() method with new one
	t.hide=function(){dhtmlmodal.close(this)} //OVERWRITE default t.hide() method with new one
return t
},


loadveil:function(backcolor,isShow){
	var d=dhtmlwindow
	d.getviewpoint()
	this.docheightcomplete=(d.standardbody.offsetHeight>d.standardbody.scrollHeight)? d.standardbody.offsetHeight : d.standardbody.scrollHeight
	this.interVeil.style.width=d.docwidth+"px" //set up veil over page
	this.interVeil.style.height=this.docheightcomplete+"px" //set up veil over page
	this.interVeil.style.left=0 //Position veil over page
	this.interVeil.style.top=0 //Position veil over page
	this.interVeil.style.visibility=isShow //Show veil over page
	this.interVeil.style.display="block" //Show veil over page

	this.interVeil.style.backgroundColor=backcolor //'#99FFCC'
},

adjustveil:function(){ //function to adjust veil when window is resized
	if (this.interVeil && this.interVeil.style.display=="block") //If veil is currently visible on the screen
		this.loadveil() //readjust veil
},


close:function(t){ //user initiated function used to close modal window

	t.contentDoc=(t.contentarea.datatype=="iframe")? window.frames["_iframe-"+t.id].document : t.contentarea //return reference to modal window DIV (or document object in the case of iframe
	var closewinbol=dhtmlwindow.close(t)
	if (closewinbol){ //if var returns true
		this.veilstack--
		if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
			this.interVeil.style.display="none"
 }
},

forceclose:function(t){ //function attached to default "close" icon of window to bypass "onclose" event, and just close window
	dhtmlwindow.rememberattrs(t) //remember window's dimensions/position on the page before closing
	t.style.display="none"
	this.veilstack--
		if (this.veilstack==0) //if this is the only modal window visible on the screen, and being closed
			this.interVeil.style.display="none"
},

show:function(t){
	dhtmlmodal.veilstack++
	dhtmlmodal.loadveil()
	dhtmlwindow.show(t)
}
} //END object declaration


var timerlen = 5;
var slideAniLen = 250;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname){
		try{
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
			}
	catch(e){
		errorCatch(e);
	}
	
}

function slideup(objname){
			try{
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
					}
	catch(e){
		errorCatch(e);
	}
}

function startslide(objname){
	try{
        obj[objname] = document.getElementById(objname);

        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style.height = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
					}
	catch(e){
		errorCatch(e);
	}
}

function slidetick(objname){
	try{
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;

                obj[objname].style.height = d + "px";
        }
					}
	catch(e){
		errorCatch(e);
	}

        return;
}

function endSlide(objname){
	try{
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style.height = endHeight[objname] + "px";

        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);
					}
	catch(e){
		errorCatch(e);
	}

        return;
}

function toggleSlide(objname){
	try{
	//alert(objname);
  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
  }else{
    // div is not hidden, so slide up
    slideup(objname);
  }
  			}
	catch(e){
		errorCatch(e);
	}
}

function highlightCurrentPage(liName){
	try{	
		var liObj = document.getElementById(liName);
		liObj.className = 'selectedMenueItem';
	}
	catch(e){
		errorCatch(e);
	}
}


document.write('<div id="interVeil"></div>');
dhtmlwindow.addEvent(window, function(){if (typeof dhtmlmodal!="undefined") dhtmlmodal.adjustveil()}, "resize");

window.onerror = null;//uncoughtErrorCatch();