globalVarDebug = false;
function changeClass(obj,ClassName) {
	try{
		if(obj!=null)
		{
			obj.className=ClassName;
		}
	}
	catch(e){
		errorCatch(e);
	}
		
}

// JavaScript Document
var smooth_timer = new Array();
var smooth_height = new Array();

function obj(id){
	try{
		return ((document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']"));
	}
	catch(e){
		errorCatch(e);
	}		
}

function smoothHeight(id, targetHeight, step, freq, mode){
	try{
			
		var cObj = obj(id);
	
		if (cObj != null)
		{
			if(targetHeight<=0)
				targetHeight=1;
	
			var currentHeight = smooth_height[id];
	
			if(currentHeight==null)
				currentHeight=0;
	
			diff = targetHeight - currentHeight;
			if (diff != 0)
			{
				newHeight = (diff > 0) ? currentHeight + step : currentHeight - step;
				
				if(diff>0 && newHeight>targetHeight)
					newHeight=targetHeight;
				if(diff<0 && newHeight<targetHeight)
					newHeight=targetHeight;
	
				cObj.style.height = newHeight + "px";
				
				if (smooth_timer[id]!=null)
					window.clearTimeout(smooth_timer[id]);
	
				smooth_height[id] = newHeight;
				smooth_timer[id] = window.setTimeout("smoothHeight('" + id + "'," + targetHeight + "," + step + "," + freq + ",'" + mode + "')", freq);
			}
			else if (mode != "o")
			{
				smooth_height[id] = 0;
				cObj.style.display="none";
			}
		}
	}
	catch(e){
		errorCatch(e);
	}
}

function tog(id,height,step,freq)
{
	try{
		var cObj = obj(id);
	
		if(height==null)
			height=210;
		if(step==null)
			step=10;
		if(freq==null)
			freq=10;
	
		if (cObj != null)
		{
			if (cObj.style.display=="none")
			{
				cObj.style.display="";
				smoothHeight(id, height, step, freq, 'o');
				return true;
			}
			else
			{
				smoothHeight(id, 0, step, freq, 'c');
				return false;
			}
		}
	}
	catch(e){
		errorCatch(e);
	}		
}
	
function expandProductCat(catID){
	try{
		var iframe
		iframe = document.getElementById("detailsFrame");
		if (iframe!=null){
			iframe.src = '/products/CatDetails.html?id='+catID;	
		}
		else{
			window.location = '/products/?id='+catID;
		}
	}
	catch(e){
		errorCatch(e);
	}
}
	
function showProduct(prodID){
	try{
		var iframe
		iframe = document.getElementById("detailsFrame");
		if (iframe!=null){
			iframe.src = '/products/details.html?id='+prodID;	
		}
		else{
			window.location = '/products/?id='+prodID;
		}
	}
	catch(e){
		errorCatch(e);
	}
	
}
function showCategory(catID){
		
			//alert(window.location);
			//if (window.location == '')	
			//tog('cat'+catID);		
		}	
	//copy text functions
function getClipboard(){
	try{
		// Internet Explorer
		if (window.clipboardData)
		{
			return(window.clipboardData.getData('Text'));
		}
		// Mozilla
		else if (window.netscape)
		{
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
	
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;
	
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans) return;
	
			trans.addDataFlavor('text/unicode');
	
			clip.getData(trans,clip.kGlobalClipboard);
	
			var str = new Object();
			var len = new Object();
	
			try
			{
				trans.getTransferData('text/unicode',str,len);
			}
			catch(error)
			{
				return;
			}
	
			if (str)
			{
				if (Components.interfaces.nsISupportsWString) // deze werkte bij mij alleen in NS7
					str=str.value.QueryInterface(Components.interfaces.nsISupportsWString);
				else if (Components.interfaces.nsISupportsString) // en deze alleen in Mozilla 1.2
					str=str.value.QueryInterface(Components.interfaces.nsISupportsString);
				else
					str = null;
			}
	
			if (str)
				return(str.data.substring(0,len.value / 2));
		}
	
		return;
	}
	catch(e){
		errorCatch(e);
	}		
}

function setClipboard(objectName){
	try{
			
		var textAreaCollection = document.getElementsByTagName("textArea");
		var textAreaLength = textAreaCollection.length;
		for (i=0;i<textAreaLength;i++){
				if (textAreaCollection[i].className == "code_highlight");
					textAreaCollection[i].className = "";
		}
		
		var textBox;
		textBox = document.getElementById(objectName);
		textBox.focus();
		textBox.select();
		textBox.className = "code_highlight";
		// Internet Explorer
		if (window.clipboardData) 
		{
			var therange;
			therange=textBox.createTextRange();
			therange.execCommand("Copy");
		}
		// Mozilla
		else if (window.netscape) 
		{ 
			alert("You are not using Internet Explorer \r\nWe have selected the code\r\nYou must hit the Contol and C keys to copy");
		}
	
		return true;
	}
	catch(e){
		errorCatch(e);
	}		
}

var lastLayer = "";
function showLayer(layerName){
	try{
		if (document.getElementById)
		{
			objLayer = document.getElementById(layerName);
			objLastLayer = document.getElementById(lastLayer);

			if(objLayer.style.display=="block")
			{
				objLayer.style.display="none";
				lastLayer = ""
			}
			else
			{
				if(objLastLayer) objLastLayer.style.display="none";
				objLayer.style.display="block";
				lastLayer = layerName
			}
		}
	}
	catch(e){
		errorCatch(e);
	}	
}
	
// Retrieve the rendered height of an element
function getObjectHeight(id){
	try{
		var elem = document.getElementById(id);
		var result = 0;
		
		if (elem.offsetHeight)
			result = elem.offsetHeight;
		else if (elem.clip && elem.clip.height)
			result = elem.clip.height;
		else if (elem.style && elem.style.pixelHeight)
			result = elem.style.pixelHeight;
	
		return parseInt(result);
	}
	catch(e){
		errorCatch(e);
	}	
}
var lastHelpVisible = 0;

function showHelp(divID){
	try{
		var activeDiv, hlpHTML;
		activeDiv = document.getElementById("help"+divID);
		hlpHTML = document.getElementById("helpHTML").innerHTML;
		hideHelp();
		lastHelpVisible = divID;
		activeDiv.innerHTML = hlpHTML;
	}
	catch(e){
		errorCatch(e);
	}		

}

function hideHelp(){
	try{
		if (lastHelpVisible != '' || lastHelpVisible != 0 ){
			var activeDiv
			activeDiv = document.getElementById("help"+lastHelpVisible);
			activeDiv.innerHTML = "";
		}
	}
	catch(e){
		errorCatch(e);
	}		
}
function advancedCode(bannerID){
	try{	
		window.open( '/banners/advancedoptions.html?id='+bannerID, 'advancedOptions', 'height=200,width=400,titlebar=0,menubar=0,toolabrs=0,resizable=0');
	}
	catch(e){
		errorCatch(e);
	}		
}
function hideShowDefault(defaultStr, formObject, focusType){
	try{	
		if (focusType == 0){
			if (formObject.value == "" || formObject.value == null){
					formObject.value = defaultStr;
			}
		}
		else{
			if (formObject.value == defaultStr){
					formObject.value = "";
			}
		}
	}
	catch(e){
		errorCatch(e);
	}		
}

function getImageCode(){
	try{	
		var img, imgBox;
		img = document.getElementById("ProductShot");
		imgBox = document.getElementById("productImage");
		imgBox.value = img.src;
	}
	catch(e){
		errorCatch(e);
	}		
}

function addRemoveRotatingBanners(id){
	try{	
		var activeCampaign = getCookie("activeCampaign");
		if	(parseInt(activeCampaign) == 0)
		{
			alert("You must select a campaign first");	
			return false;
		}
		else
		{
			var rsImg = document.getElementById("addRemoveRotatingBanener"+id);
			rsImg.src = "/campaigns/rs.html?rsadd="+id+"&c="+activeCampaign+"&r="+Math.random();
			//document.write(rsImg.src);
		}
	}
	catch(e){
		errorCatch(e);
	}		
}

var lastActiveCampaign;
function selectActiveCampaign(id, type){
	try{	
		var expDate = new Date()
		expDate.setDate(expDate.getDate()+30)
		setCookie("activeCampaign", id, expDate, "/", "");
		setCookie("activeCampaignType", type, expDate, "/", "");
		changeDisplayActiveCampaign(lastActiveCampaign, id);
	
		lastActiveCampaign = id
		//alert("Campaign #"+testCookie+" is active");
	}
	catch(e){
		errorCatch(e);
	}		
}
function getActiveCampaign(){
	try{	
		var campaignID;
		campaignID = getCookie("activeCampaign");
		lastActiveCampaign = campaignID;
		return campaignID;
	}
	catch(e){
		errorCatch(e);
	}		
}
function setActiveCampaign(id){
	try{	
		var expDate = new Date();
		expDate.setDate(expDate.getDate()+30);
		setCookie("activeCampaign", id, expDate, "/", "");
		lastActiveCampaign = id;
	}
	catch(e){
		errorCatch(e);
	}		
}
function changeDisplayActiveCampaign(oldCampaignID, newCampaignID){
	try{
		var oldCol1 = document.getElementById("col1CampaignID"+oldCampaignID);
		var oldCol2 = document.getElementById("col2CampaignID"+oldCampaignID);
		var newCol1 = document.getElementById("col1CampaignID"+newCampaignID);
		var newCol2 = document.getElementById("col2CampaignID"+newCampaignID);
		oldCol1.className = "CampaignNonSelectedRowIcon";
		oldCol2.className = "CampaignNonSelectedRow";
		newCol1.className = "CampaignSelectedRowIcon";
		newCol2.className = "CampaignSelectedRow";
		changeCampaignIds(oldCampaignID, newCampaignID);
		getRotatingBanners(newCampaignID);
	}
	catch(e){
		errorCatch(e);
	}
}

function changeCampaignIds(oldID, newID){
	try{	
		var textAreaCollection = document.getElementsByTagName("textArea");
		var textAreaLength = textAreaCollection.length;
		var valueOfTextArea
		for (i=0;i<textAreaLength;i++){
				valueOfTextArea = textAreaCollection[i].value;
				textAreaCollection[i].value = valueOfTextArea.replace("&c="+oldID, "&c="+newID);
		}	
	}
	catch(e){
		errorCatch(e);
	}		
}

var campaignOptionsVisible = false;
var originalDivHTML;
function toggleCampaignOptions(objName){
	try{		
		var placeHolder = document.getElementById(objName);
		var divPop = "<h1>test</h1>";
		if (campaignOptionsVisible == false){
			originalDivHTML = placeHolder.innerHTML;
			placeHolder.innerHTML = originalDivHTML + divPop;
			campaignOptionsVisible = true;
		}
		else{
			placeHolder.innerHTML = originalDivHTML;
			campaignOptionsVisible = false;
		}
	}
	catch(e){
		errorCatch(e);
	}		
}

var selectedRotatingBanners
function getRotatingBanners(campaignID){
	try{
		var scriptObj = document.createElement("script");
		scriptObj.src = "/campaigns/rs.html?selRB="+campaignID+"&r="+Math.random();
	
		document.body.appendChild(scriptObj);
	}
	catch(e){
		errorCatch(e);
	}		
}

function markSelectedRotatingBanners(bannerIDs){
	try{
		var bannerArray  = bannerIDs.split(",");
		var bannerCount = bannerArray.length;
		var tmpHolder;
		var idHolder = document.getElementById("mediaIds").value;
		
		var mediaIds = idHolder.split(",");
		var mediaIdCount = mediaIds.length;
		var bannerSelected = false;
		for (i=0;i<mediaIdCount; i++){
			tmpHolder = document.getElementById("addRemoveRotatingBanener"+mediaIds[i]);
			if (tmpHolder != null){
				for (j = 0; j<bannerCount;j++){
					//alert("mediaID ="+mediaIds[i]+" bannerID = "+bannerArray[j])
					if (mediaIds[i] == bannerArray[j]){  
						bannerSelected = true;
						j = bannerCount;
					}
					else{
						bannerSelected = false;	
					}
				}
				if (bannerSelected == true){
					tmpHolder.src = "/images/icon_removerotate.gif";}
				else{
					tmpHolder.src = "/images/icon_addtorotate.gif";}
				bannerSelected = false
			}
		}
	}
	catch(e){
		errorCatch(e);
	}
}

function previewRotatingBanner(affiliateID){
	try{	
		var activeCampaign = getCookie("activeCampaign");
		var divObj = document.getElementById("rotatingBannerPreview");
		var previewHTML;
		var previewHTML = "<div class='previewBannerArea'>test<script src='/cgi/rotater.cgi?aid="+affiliateID+"&c="+activeCampaign+"' language='javascript'></script></div>"
		if (divObj.innerHTML == ""){
			var newDivObj = document.createElement('div');
			divObj.appendChild(newDivObj);
			newDivObj.setAttribute('class','previewBannerArea');
			var bannerScript = document.createElement('script');
			newDivObj.appendChild(bannerScript);
			//bannerScript.setAttribute('src', "http://zenmed.com/cgi/rotater.cgi?aid="+affiliateID+"&c="+activeCampaign);
			bannerScript.setAttribute('language','javaScript');
		}
		else{
			divObj.innerhtml = "";
		}
	}
	catch(e){
		errorCatch(e);
	}	
}

var divHolder = null;
function createCampaignTable(campaignsArray){
		var divHolder = document.getElementById("campaignHolder");
	
		var selectedCampaign = parseInt(getCookie("activeCampaign"));
		var newCampaignList = document.createElement('div');
	
		if(isNaN(selectedCampaign))
		{
			var expDate = new Date();
			expDate.setDate(expDate.getDate()+30);
			setCookie("activeCampaign", 0, expDate, "/", "");
	
			selectedCampaign = 0;
		}
	
		if(divHolder.firstChild!=null)
			divHolder.replaceChild(newCampaignList, divHolder.firstChild);
		else
			divHolder.appendChild(newCampaignList);
		
		for (var i=0;i<campaignsArray.length; i++)
		{
			CampaignItem(campaignsArray[i].id,campaignsArray[i].name);
		}
}

function CampaignItem(id,name){
		var divHolder = document.getElementById("campaignHolder");
		var selectedCampaign = parseInt(getCookie("activeCampaign"));
	
		if(isNaN(selectedCampaign)) selectedCampaign = 0;
	
		var newRow = document.createElement('div');
		newRow.className = "campaign_normal";
		
		if(selectedCampaign==id)
			newRow.className = "campaign_active";
	
		newRow.id = 'campaign_'+id;
		newRow.style.cursor = "pointer";
		newRow.appendChild(document.createTextNode(name));
	
		newRow.onclick = new Function('CampaignSelect("'+id+'");');
		newRow.onmouseover = new Function('CampaignOver("'+id+'");');
		newRow.onmouseout = new Function('CampaignOut("'+id+'");');
	
		if(document.getElementById(newRow.id)!=undefined)
			divHolder.firstChild.replaceChild(newRow,document.getElementById(newRow.id));
		else
			divHolder.firstChild.appendChild(newRow);
}

function CampaignItemDelete(id){
	var selectedCampaign = parseInt(getCookie("activeCampaign"));
	var obj = document.getElementById('campaign_'+id);
	
	if(obj!=null)
	{
		if(id==selectedCampaign)
			CampaignSelect(0);

		obj.parentNode.removeChild(obj);

		var found = false;
		for (var i=0;i<campaignsArray.length; i++)
		{
			if(found)
				campaignsArray[i-1] = campaignsArray[i];

			if(campaignsArray[i].id==id)
				found = true;
		}

		if(found)
			campaignsArray.length--;
	}
}

function CampaignScrollToActive(){
	var campaign_id = parseInt(getCookie('activeCampaign'));

	if(isNaN(campaign_id)) campaign_id=0;

	CampaignScrollTo(campaign_id);
}

function CampaignScrollTo(campaign_id){
	if(document.getElementById('campaign_'+parseInt(campaign_id))!=null)
		document.getElementById('campaignHolder').scrollTop = parseInt(document.getElementById('campaign_'+parseInt(campaign_id)).offsetTop)-4;
}

function CampaignSelect(campaign_id){
	var obj = document.getElementById('campaign_'+campaign_id);
	var selectedCampaign = parseInt(getCookie("activeCampaign"));

	if(selectedCampaign != campaign_id)
	{
		var old_obj = document.getElementById('campaign_'+selectedCampaign);
		if(old_obj!=null)
			old_obj.className = 'campaign_normal';

		//alert(campaign_id);
		var expDate = new Date();
		expDate.setDate(expDate.getDate()+30);
		setCookie("activeCampaign", campaign_id, expDate, "/", "");

		/*Rewrite Banners Here*/
		var banners = document.getElementsByTagName("textarea");
		for(var i=0; i<banners.length; i++)
		{
			if(banners[i].className=='copyBox' || banners[i].className=='code_highlight')
			{
				banners[i].value=banners[i].value.replace('&c='+selectedCampaign,'&c='+campaign_id);
			}
		}

		getRotatingBanners(campaign_id);

		obj.className = 'campaign_active';
	}
}

function CampaignOver(campaign_id){
	var obj = document.getElementById('campaign_'+campaign_id);
	var selectedCampaign = parseInt(getCookie('activeCampaign'));
	var obj_container = document.getElementById('campaignHolder');

	if(selectedCampaign != campaign_id && campaign_id>=0)
		obj.className = 'campaign_hover';

	var top = getObjTop(obj) - (campaign_id>=0?obj_container.scrollTop:0);
	var left = getObjLeft(obj);

	CampaignDetails(top,left,campaign_id);
}

function CampaignOut(campaign_id){
	var obj = document.getElementById('campaign_'+campaign_id);
	var selectedCampaign = parseInt(getCookie("activeCampaign"));

	if(selectedCampaign != campaign_id && campaign_id>=0)
		obj.className = 'campaign_normal';

	campaign_timeout();
}

function campaign_timeout(){
	if(campaign_timeout_obj!=null)
		window.clearTimeout(campaign_timeout_obj);

	campaign_timeout_obj = window.setTimeout("campaign_popup_close()",2000);
}

function campaign_cleartimeout(){
	if(campaign_timeout_obj!=null)
		window.clearTimeout(campaign_timeout_obj);
}

var campaign_popup = null;
var campaign_timeout_obj = null;
var campaign_script = null;
var last_campaign_id = -1;
function CampaignDetails(top, left, campaign_id){
	var new_url = "/js/campaign.js.cgi?id="+ campaign_id +"&rand="+ Math.random();

	campaign_cleartimeout();

	/*Create if not already*/
	if (campaign_popup==null)
	{
		campaign_popup = document.createElement("div");
		campaign_popup.style.position = "absolute";
		campaign_popup.style.display = "none";
		campaign_popup.style.top = '0px';
		campaign_popup.style.left = '0px';
		campaign_popup.style.marginTop = "0px";
		campaign_popup.style.width = "290px";
		campaign_popup.style.padding = "0px";
		campaign_popup.style.border = "1px solid black";
		campaign_popup.style.background = "#fafafa";
		campaign_popup.style.zIndex = "100000000";
		campaign_popup.onmouseover = campaign_cleartimeout;
		campaign_popup.onmouseout = campaign_timeout;

		document.body.appendChild(campaign_popup);
	}

	if(campaign_id!=last_campaign_id || campaign_popup.style.display == 'none')
	{
		campaign_popup.style.display = 'none';
		while(campaign_popup.innerHTML!='')
			campaign_popup.innerHTML = '';

		campaign_popup.style.top = top+'px';
		campaign_popup.style.left = (left-290-6)+'px';

		if(campaign_script!=null)
				document.body.removeChild(campaign_script);

		campaign_script = document.createElement("script");
		campaign_script.setAttribute("type","text/javascript");
		campaign_script.setAttribute("src",new_url);
		document.body.appendChild(campaign_script);
	}

	last_campaign_id = campaign_id;
}

function campaign_popup_close(){
	campaign_cleartimeout();

	if(campaign_popup!=null)
		campaign_popup.style.display='none';

	last_campaign_id=-1;
};

function changeRotatingSpeed(campaignID, affiliateID){
	try{
		var iframe = document.getElementById("rbIframe"+campaignID);
		var txtBox = document.getElementById("rb"+campaignID);
		var timerBox = document.getElementById("timerRB"+campaignID);
		var timerValue = timerBox.value;
		try{
			timerValue = parseFloat(timerValue);
		}
		catch(e){
			timerValue = 5;
			timerBox.value = timerValue;
		}
		if (isNaN(timerValue))
			timerValue = 5;
		iframe.src= "/banners/rotatingBanners.html?id="+campaignID+"&t="+timerValue;
		txtBox.value = "<script language=\"javaScript\" src=\"/cgi/rotater.cgi?aid="+affiliateID+"&c="+campaignID+"&timer="+timerValue+"\">";
	}
	catch(e){
		errorCatch(e);
	}		
}

function deleteRB(campaignID){
	try{	
		var allow = confirm("Are you sure you want to remove these rotating banners?");
		if (allow){
			window.location = "/campaigns/rs.html?removeID="+campaignID
		}
	}
	catch(e){
		errorCatch(e);
	}		
}

function showCampaignHelp(){
	try{
		var divObj = document.getElementById("campaignHelp")
		if (divObj.className == "hide")
			divObj.className = "ban_help_pop";
		else
			divObj.className = "hide";
	}
	catch(e){
		errorCatch(e);
	}			
}
function CampaignUpdate(func,id,name,description){
	try{
		//alert('CampaignUpdate('+func+', '+id+', '+name+', '+description+')');
		
		var obj = document.createElement('script');
		obj.type = "text/javascript";
		obj.src = "/js/campaign_update.js.cgi?func="+escape(func)+"&id="+escape(id)+"&name="+escape(name)+"&description="+escape(description)+"&rand="+Math.random();
		document.body.appendChild(obj);
	}
	catch(e){
		errorCatch(e);
	}
	
}

function showRBpop(campaignID, width, height){
	try{
		if(height==null)
			height=500;
		else
			height+=40;
		if(width==null)
			width=500;
		else
			width+=22;

		var openWin = window.open('rotatingBanners.html?pop=yes&id='+campaignID, 'RBdisplay', 'width='+width+',height='+height+',scrolling=1,resize=1');	
	}
	catch(e){
		errorCatch(e);
	}		
}

function previewInvite(){
	try{	
		var divObj = document.getElementById("previewEmail");
		if (divObj.className =="hide")
			divObj.className = "";
		else
			divObj.className = "hide";
	}
	catch(e){
		errorCatch(e);
	}
		
}

function showPaymentHistory(){
	try{
		var divObj = document.getElementById("paymentHistoryWin");
		var dateObj = new Date();
		var dateStr = dateObj.getFullYear()+'/'+dateObj.getMonth()+'/'+dateObj.getDate();
		var html = '<table width="300" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';
		html += '<tr><td colspan="2" align="left" class="bluebar" style="padding: 0 2px 0 2px;"><div style="float: right; text-align: right;"><a href="#" onClick="showPaymentHistory(); return false;"><img src="/images/close_icon.gif" border="0"></a></div><div style="float: right; text-align: right; margin-right: 2px;">'+dateStr+'</div>Payment Status</td></tr><tr><td colspan="2">';
		html += '<iframe src="/account/paymenthistory.html" width="300" height="110" frameborder="0" id="paymentHistoryFrame" name="paymentHistoryFrame"></iframe></td></tr>';
		html += '<tr><td bgcolor="#CCCCCC" colspan="2"><font size="1"><b>*Payment made in the ';
		html += 'second week of every month</b></font><br>';
		html += '<a href="#" onClick="paymentHistoryFrame.print(); return false;"><img src="/images/icon_printreport.gif" border="0"></a></td>';
		html += '</tr></table>';
		if (divObj.style.display != "block" && divObj.style.display != "")
		{
			divObj.innerHTML = html;
			divObj.style.display = 'block';
		}
		else
		{
			divObj.style.display = 'none';
			divObj.innerHTML = "";
		}
	}
	catch(e){
		errorCatch(e);
	}		
}
function toggleFakeBrowser(retItem){
	try{
		var divObj = document.getElementById("fakeBrowserDiv");
		var html;
		html='<div class="fakeBrowserWrapper"><div class="bluebar" style="padding:2px 3px 1px 0px;"><div style="width:290px; float:left; margin-left:10px;">ZENMEDŽ Link Builder Browser</div>';
		html+='<div style="float:right; width:17px;"><a href="#" onclick="toggleFakeBrowser(); return false;"><img src="/images/close_icon.gif" border="0"></a></div></div><div class="fakeAddressBar">Address: <input value="Loading page...." readonly="readonly" name="fakeAddressBar" id="fakeAddressBar" class="fakeAddressUrl" type="text"><div class="fakeUrlBtn"><a href="#" id="returnURLlink" onclick="getFakeBrowserURL(); return false;"><img src="/images/icon_useurl.gif " border="0"></a></a></div>';
		html+='<div class="fakeBrowser"><iframe src="http://zenmed.com" width="797" height="450" id="fakeBrowserObj" name="fakeBrowser" onload="updateFakeAddressBar();" frameborder="0"></iframe>';
		html+='</div></div><div class="bluebar">&nbsp;</div>';
		if (divObj.innerHTML == ""){
			divObj.innerHTML = html;
			divObj.className = "";
		}
		else if(divObj.innerHTML != "" && divObj.className == "hide"){
			divObj.className = ""
		}
		else{
			divObj.className= "hide";
		}
		var linkObj = document.getElementById("returnURLlink")
		linkObj.onclick = new Function('getFakeBrowserURL("'+retItem+'"); return false');
	}
	catch(e){
		errorCatch(e);
	}		

}
function getFakeBrowserURL(retItem){
	try{	
		var url = document.getElementById("fakeAddressBar").value;
		if (retItem == 'text')
			var elSel = document.getElementById('pageList');
		else
			var elSel = document.getElementById('PPCpageList');
		if (elSel.selectedIndex >= 0) {
			var elOptNew = document.createElement('option');
			elOptNew.text = url;
			elOptNew.value = url;
			var elOptOld = elSel.options[elSel.selectedIndex];  
			elOptNew.selected = true;
		try {
			elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
			elSel.selectedIndex;
		}
		catch(ex) {
			elSel.add(elOptNew, elSel.selectedIndex); // IE only
		}
	  }
		toggleFakeBrowser();
		elSel.focus();
		getLinkBuilderCode(url);
		getPPCLinkBuilderCode(url);
	}
	catch(e){
		errorCatch(e);
	}	
	
}
function updateFakeAddressBar(){
	try{	
		var fakeAddressBar = document.getElementById("fakeAddressBar");
		try{
			fakeAddressBar.value = frames['fakeBrowser'].location.href;
		}
		catch(e){
			fakeAddressBar.value = document.getElementById("fakeBrowserObj").location;
		}
	}
	catch(e){
		errorCatch(e);
	}
}

function getLinkBuilderCode(url){
	try{	
		var affiliateID = document.getElementById("affiliateID");
		var pageList = document.getElementById("pageList");
		var language = document.getElementById("language");
		var campaignID = document.getElementById("campaignID");
		var textForLink = document.getElementById("textForLink");
		var makeHTMLlink = document.getElementById("makeHTMLLink");
		var codeBox = document.getElementById("codeBox");
		var linkReturnVal;
		var linkURL = url;
		if (linkURL == null || linkURL == "")
			linkURL = pageList.value	
		linkReturnVal = linkURL;
		if (linkURL.indexOf("?") > 0)
			linkReturnVal+="&"
		else
			linkReturnVal+="?"
		linkReturnVal+='a='+affiliateID.value;
		linkReturnVal+='&c='+campaignID.value;
		if (makeHTMLlink.value == 'yes'){
			linkReturnVal = '<a target="_blank" href="'+linkReturnVal+'">'+textForLink.value+'</a>';
			textForLink.disabled = false;
		}
		else{
			textForLink.disabled = true;
		}
		codeBox.value = linkReturnVal;		
	}
	catch(e){
		errorCatch(e);
	}		
}
function getPPCLinkBuilderCode(url){
	try{
		var affiliateID = document.getElementById("PPCaffiliateID");
		var pageList = document.getElementById("PPCpageList");
		var campaignID = document.getElementById("PPCcampaignID");
		var textForLink = document.getElementById("PPCtextForLink");
		var codeBox = document.getElementById("PPCcodeBox");
		var linkReturnVal;
		var linkURL = url;
		if (linkURL == null || linkURL == "")
			linkURL = pageList.value	
		linkReturnVal = linkURL;
		if (linkURL.indexOf("?") > 0)
			linkReturnVal+="&"
		else
			linkReturnVal+="?"
		linkReturnVal+='a='+affiliateID.value;
		linkReturnVal+='&c='+campaignID.value;
		linkReturnVal+='&q='+textForLink.value;
		codeBox.value = linkReturnVal;
	}
	catch(e){
		errorCatch(e);
	}		
}


function toggleLinkBuilder(){
	try{	
		var ppcObj = document.getElementById("ppcLinks");
		var textObj = document.getElementById("textLinks");
		if (textObj.className == ""){
			textObj.className = "hide";
			ppcObj.className = "";
		}
		else{
			textObj.className = "";
			ppcObj.className = "hide";	
		}
	}
	catch(e){
		errorCatch(e);
	}	
}
//GENERAL COOKIE FUNCTIONS
function getCookie(name){
	try{	
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
		} else
		begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	}
	catch(e){
		errorCatch(e);
	}		
}

function setCookie(name, value, expires, path, domain, secure) {
	try{	
		var curCookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : ""); //+
		//((secure) ? "; secure" : "");
		document.cookie = curCookie;
	}
	catch(e){
		errorCatch(e);
	}		
}

function deleteCookie(name, path, domain) {
	try{	
		if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}
	catch(e){
		errorCatch(e);
	}		
}

//get left of element function
function getObjLeft(el){
	try{	
		var ol=el.offsetLeft;
		while ((el=el.offsetParent) != null) { ol += el.offsetLeft; };
		return parseInt(ol);
	}
	catch(e){
		errorCatch(e);
	}		
};
 
//get top of element function
function getObjTop(el){
	try{	
		var ot=el.offsetTop;
		while((el=el.offsetParent) != null) { ot += el.offsetTop; };
		return parseInt(ot);
	}
	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+"&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 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")
		//}
	}	
}