function msieversion()
// return Microsoft Internet Explorer (major) version number, or 0 for others
// This function works by finding the "MSIE " string and extracting the version number
// following the space, up to the decimal point for the minor version which is ignored.
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 )		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
	else
		return 0	// is other browser
}

//check for IE < 7 and if found set iefix to true and use iefix for specific IE fixes throughout functions
var checkv = msieversion();


if(checkv == '6'){
	document.write('<style type="text/css"> img, div { behavior: url(http://exchange.contextweb.com/buyingdesk/code/iepngfix.htc) } </style>');
}



//Check for AFF in URL if so Append Cookie
var DocURL = document.URL;
var splitURL = DocURL.split('aff=');

if(splitURL[1] == "mradik" || splitURL[1] == "abatext")
	logHouseAdClicks(splitURL[1])

function logHouseAdClicks(affCode){
	xmlHttp=GetXmlHttpObject();
	url = 'http://exchange.contextweb.com/buyingdesk/code/phpTrackHouseAdClicks.php';

	var parameters = "refURL=" + encodeURI(document.referrer) + "&affCode=" + encodeURI(affCode)

	url=url+"?sid="+Math.random();
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}

if(splitURL[1])
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+31)
	document.cookie="affAdvCookie=" +escape(splitURL[1])+(";path=/;expires="+exdate.toGMTString())//
	
}

function readCookie(name) {
	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;
}

//Rollover Function 'Roll-on'

function imgOn(imgName) {
	if (document.images) {
		$(imgName).src = eval(imgName + "on.src");
	}
}

//Rollover Function 'Roll-off' 

function imgOff(imgName) {
	if (document.images) {
		$(imgName).src = eval(imgName + "off.src");

	}
}

//Set For Loggin on or off
doLogging=false;

function log(stuff){
	if(doLogging) {
		if(window['console']!=undefined){
			if(window['console']!=null){
				console.log(stuff.toString());
			}
		}
	}

}




var rarPage = window.location.href;
function CurrentPage(){
	log("entering getCurrent");
	log(rarPage);

	var rarPageArray = rarPage.split('/');
	
	log(rarPageArray);
	if(rarPageArray.length>0){
		return rarPageArray;
	}
	//alert(rarPageArray[rarPageArray.length - 1]);
	log("exiting getCurrent");
	return "";
}

var whosinitTabStatus = null;
var whosinitFunctionEvent = null;
window.addEvent('domready', function() {
	//if(checkv != 0 && $('livechatIcon'))
		//$('livechatIcon').style.display = 'inline';

	if($('categorizeURL'))
		if(splitURL[0] == "http://www.contextweb.com/seeouraddemo/"){
			$('categorizeURL').addEvent('keydown', function(event){
				if (event.key == 'enter') categorizeThis_replica();
			});
		}
		else{
			if(splitURL[0] == "http://www.contextweb.com/seeouraddemo/"){
				$('categorizeURL').addEvent('keydown', function(event){
					if (event.key == 'enter') categorizeThis_replica();
				});
			}
			else{
				$('categorizeURL').addEvent('keydown', function(event){
					if (event.key == 'enter') categorizeThis();
				});
			}
		}
	if($('categorizeURLrmod'))
		$('categorizeURLrmod').addEvent('keydown', function(event){
			if (event.key == 'enter') launchContextualizer();
		});
	if(checkPage[4] == 'community'){
		whosinitFunctionEvent = function(){whosinitSwitchTab(this.id);};
		$('seller').addEvent('click', whosinitFunctionEvent);
		$('seller').setStyle('cursor','pointer');

		$('advisory').addEvent('click', whosinitFunctionEvent);
		$('advisory').setStyle('cursor','pointer');
	}
});
	
	activeTab = 'buyer';


function whosinitSwitchTab(objCall){
	
	var buyerImage = '../images/whosinit_tabL';
	var sellerImage = '../images/whosinit_tabCenter';
	var advisoryImage = '../images/whosinit_tabR';

	$(objCall).removeEvents('click');
	$(objCall).setStyle('cursor','default');
	$(objCall+'Content').style.display = 'block';
	$(objCall+'Text').style.color = '#FFFFFF';
	$(objCall+'Image').src = eval(objCall +'Image') + '-on.gif';

	$(activeTab).setStyle('cursor','pointer');
	$(activeTab+'Content').style.display = 'none';
	$(activeTab+'Text').style.color = '#336699';
	$(activeTab+'Image').src =  eval(activeTab +'Image') + '-off.gif';
	$(activeTab).addEvent('click',whosinitFunctionEvent);

	activeTab = objCall;
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

var response = null;
function navChange() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		$('loadingDiv').style.display = 'none';
		$('popContextualizer').style.zIndex = '15';
		responseHandler(xmlHttp.responseText);
		logcatAjaxRequest('contextualizer');
	}
}


function getAjaxRequest(url,Catlogging){
	xmlHttp=GetXmlHttpObject();
	
	if(!Catlogging)
		xmlHttp.onreadystatechange =  navChange;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

var checkPage = CurrentPage();
var urlSet = null;

for(i=0; i<checkPage.length; i++){
	if(checkPage[i] == 'buyingdesk')
		urlSet = rarPage.split(checkPage[i]);
}

		

//set CSS for Cross Browser Fix's
if(checkv == 0)
	document.write('<link href="/buyingdesk/code/cssfix.css" rel="stylesheet" type="text/css">');
else
	document.write('<link href="/buyingdesk/code/cssfixie.css" rel="stylesheet" type="text/css">');

if (document.images) {
	
	//imgs on  
	img1on = new Image();
	img1on.src= "/buyingdesk/images/nav_buyHome-ov.gif";
	img2on = new Image();
	img2on.src= "/buyingdesk/images/nav_howitworks-ov.gif";
		img2aon = new Image();
		img2aon.src= "/buyingdesk/images/nav_Cat-on.png";
	img3on = new Image();
	img3on.src= "/buyingdesk/images/nav_community-ov.gif";
		img3aon = new Image();
		img3aon.src= "/buyingdesk/images/nav_whosinit-on.png";
	img4on = new Image();
	img4on.src= "/buyingdesk/images/nav_faq-ov.gif"; 
	signUpon = new Image();
	signUpon.src= "/buyingdesk/images/nav_Signup-on.gif"; 
	img6on = new Image();
	img6on.src= "/buyingdesk/images/nav_viewdemo-ov.gif"; 
		img6aon = new Image();
		img6aon.src= "/buyingdesk/images/nav_educationalDemo-on.png"; 
		img6bon = new Image();
		img6bon.src= "/buyingdesk/images/nav_easyDemo-on.png";

	//imgs off  
	img1off = new Image();
	img1off.src= "/buyingdesk/images/nav_buyHome.gif";
	img2off = new Image();
	img2off.src= "/buyingdesk/images/nav_howitworks.gif";
		img2aoff = new Image();
		img2aoff.src= "/buyingdesk/images/nav_Cat.png"; 
	img3off = new Image();
	img3off.src= "/buyingdesk/images/nav_community.gif"; 
		img3aoff = new Image();
		img3aoff.src= "/buyingdesk/images/nav_whosinit.png";
	img4off = new Image();
	img4off.src= "/buyingdesk/images/nav_faq.gif"; 
	signUpoff = new Image();
	signUpoff.src= "/buyingdesk/images/nav_Signup.gif"; 
	img6off = new Image();
	img6off.src= "/buyingdesk/images/nav_viewdemo.gif"; 
		img6aoff = new Image();
		img6aoff.src= "/buyingdesk/images/nav_educationalDemo.png"; 
		img6boff = new Image();
		img6boff.src= "/buyingdesk/images/nav_easyDemo.png";
}

function showDropDown(dropID){
	$('dropdown'+dropID).style.display = 'block';
	$('dropHide'+dropID).style.display = 'block';
}

function hideDropDown(dropID){
	$('dropdown'+dropID).style.display = 'none';
	$('dropHide'+dropID).style.display = 'none';
}


var SDposition = 1;
var SDsize = null;
var SDtimer = null;
var pageID = null;


function OnLoadSwap(pageCall){
	if(pageCall == 'howitworks'){
		SDsize = 8;
	}
	if(pageCall == 'buyingdesk'){
		SDsize = 4;
	}
	pageID = pageCall;
	SDtimer = setInterval('loadSwap()', 7500);
}

function loadSwap(){
	if(SDposition < SDsize){
		SDposition++;
		$('SDnumberPosition').innerHTML = SDposition;
		$('SDimage').src = "/buyingdesk/images/"+pageID+"_slide-"+(SDposition)+".gif";
		log("/buyingdesk/images/"+pageID+"_slide-"+(SDposition)+".gif")
	}
	else
		SDposition = 0;
	if(SDsize == 4 && SDposition == 2){
		$('divHoverclick').style.display = 'block';
		$('divHoverclickB').style.display = 'block';
	}
	else{
		if($('divHoverclick')){
			$('divHoverclick').style.display = 'none';
			$('divHoverclickB').style.display = 'none';
		}
	}
}

function SwapSD(direction){
	if( (direction=='up') && (SDposition < SDsize) ){
		if(SDtimer)
			clearInterval(SDtimer);
		SDposition++;
		$('SDnumberPosition').innerHTML = SDposition;
		$('SDimage').src = "/buyingdesk/images/"+pageID+"_slide-"+(SDposition)+".gif";
	}
	if( (direction=='down') && (SDposition > 1) ){
		if(SDtimer)
			clearInterval(SDtimer);
		SDposition--;
		$('SDnumberPosition').innerHTML = SDposition;
		$('SDimage').src = "/buyingdesk/images/"+pageID+"_slide-"+(SDposition)+".gif";
	}
	if(SDsize == 4 && SDposition == 2){
		$('divHoverclick').style.display = 'block';
		$('divHoverclickB').style.display = 'block';
	}
	else{
		if($('divHoverclick')){
			$('divHoverclick').style.display = 'none';
			$('divHoverclickB').style.display = 'none';
		}
	}
		
}

var questionHighlight = 'q1class';
function showquestion(question){
		var clearQuestion = $('questionArea');
		var cq = clearQuestion.getElementsByTagName('div');

		for(i=0; i < cq.length; i++){
			if(cq[i].id != 'noHide')
				cq[i].style.display = 'none';
		}


		$(questionHighlight).className = 'text';
		questionHighlight = question+'class';
		$(questionHighlight).className = 'nolink';
		$(question+'content').style.display = 'block';
	}

	function expandQ(qArea){
	if($(qArea+'Arrow').alt == 'arrowDown'){
		$(qArea+'Arrow').src = '../images/arrow.gif';
		$(qArea+'Div').style.display = 'none';
		$(qArea+'Arrow').alt = 'arrow';
	}
	else{
		$(qArea+'Arrow').src = '../images/arrowdownQ.gif';
		$(qArea+'Div').style.display = 'block';
		$(qArea+'Arrow').alt = 'arrowDown';
	}
}
var catURL = '';
function categorizeThis(launch){
	if(!launch)
		catURL = $('categorizeURL').value;
	else{
		catURL = $('categorizeURLrmod').value;
		$('categorizeURL').value = catURL;
		$('iframeTrackContextualizer').src = 'http://exchange.contextweb.com/buyingdesk/trackContextualizer.html';
	}		
	if(catURL != ''){
		$('loadingDiv').style.display = "block";
		$('popContextualizer').style.zIndex = '5';
		var catVarURLcrop = catURL;
		//alert(catURL.substr(65))
		if(catURL.substr(65))
			catVarURLcrop = catURL.substr(0,65) + '...';
		$('catVarURL').innerHTML = catVarURLcrop;
		getAjaxRequest("/buyingdesk/code/ctx.php?cwurl="+catURL);
	}
}


function launchContextualizer(){
	if($('categorizeURLrmod').value != ''){
		if(!$('divBackfade')){
			BackFadeAppendBackfadeDiv();
		}
		$('divBackfade').style.display = 'block';
		$('popContextualizer').style.display = 'block';
		categorizeThis(true);
		PopUpresize = true;
	}
}

	
function responseHandler(responseTXT){
	
	if(responseTXT == 'ctx limit reached'){
		$('catHead').innerHTML = 'WARNING: Request Limit Reached!';
		CatHTMLbuild = '<span class="clsRed clsBold">You have exceeded the maximum amount of search requests per day.</span>';
		$('categoryFill').innerHTML = CatHTMLbuild;
		return;
	}
	var testResponse = responseTXT;
	testResponse = testResponse.split('Warning');
	log(testResponse[1] + " ---------test response ------------- ");
	if(testResponse[1]){
		responseTXT = '';
	}

	log('responseTXT========================('+responseTXT+')');
	var parseResponse = responseTXT.split('<br />');
	log(parseResponse);
	var parseResponselvl2 = new Array;
	for(i=0; i < parseResponse.length - 1; i++){
		parseResponselvl2[i] = parseResponse[i].split(':');
	}
	
	var mainCategories = new Array;
	var subCategories = new Array;
	for(i=0; i < parseResponselvl2.length; i++){
		mainCategories[i] = parseResponselvl2[i][0];
		subCategories[i] = parseResponselvl2[i][1];
	}
		var CatHTMLbuild = '';

	
	var parsesubCategories = new Array;
	for(i=0; i < subCategories.length; i++){
		parsesubCategories[i] = subCategories[i].split('|');
	}
	var HTMLp1 = '<ul class="horizontalAlign" style="height:32px; clear:left; margin-bottom:4px"><li style="margin-right:4px"><div style="width:33px"><b class="catNum1"></b><b class="catNum2"></b><b class="catNum3"></b><b class="catNum4"></b><div class="contentcatNum"><div><span class="cls14 clsBold clsGreen">'
	var HTMLp2 = '</span></div></div><b class="catNum4"></b><b class="catNum3"></b><b class="catNum2"></b><b class="catNum1"></b></div></li><li><div style="width:506px"><b class="catName1"></b><b class="catName2"></b><b class="catName3"></b><b class="catName4"></b><div class="contentcatName"><div class="cls12 clsDarkGrey">';
	var HTMLp3 = '</div><b class="catName4"></b><b class="catName3"></b><b class="catName2"></b><b class="catName1"></b></div></li></ul>';
	$('catHead').innerHTML = 'Here are your top 5 category results.';
	if(!mainCategories[0]){
		$('catHead').innerHTML = 'WARNING: Page cannot be categorized!';
		CatHTMLbuild = '<span class="clsRed clsBold">ADSDAQ cannot assign a Category to this page.</span><br /><span class="clsRed">(ADSDAQ does <u>not</u> serve ads to pages that cannot be categorized)</span><br /><br />Some possible reasons for this are:<br /><br />1 - There is not enough text on the page to be able to accurately categorize it<br />2 - The content of the page is all coded in Flash so it cannot be automatically read and categorized by ADSDAQ.';
				$('categoryFill').innerHTML = CatHTMLbuild;
		return;
	}
	for(i=0; i < mainCategories.length; i++){
		CatHTMLbuild += HTMLp1 + (i+1)+'.'+HTMLp2
		for(c=0; c < parsesubCategories[i].length; c++){
			if(parsesubCategories[i][c] == 'Block'){
				$('catHead').innerHTML = 'WARNING: Blocked Category detected!';
				var HTMLp2 = '</span></div></div><b class="catNum4"></b><b class="catNum3"></b><b class="catNum2"></b><b class="catNum1"></b></div></li><li><div style="width:506px"><b class="catName1"></b><b class="catName2"></b><b class="catName3"></b><b class="catName4"></b><div class="contentcatName"><div class="cls12 clsRed">';
				CatHTMLbuild = HTMLp1 +'1.'+HTMLp2;
				CatHTMLbuild += parsesubCategories[i][c] +' > ';
				CatHTMLbuild += '<span class="cls14 clsBold clsRed">'+mainCategories[i]+'</span></div>';
				CatHTMLbuild += HTMLp3 +'<br /> <span class="clsRed"><b>NOTE:</b> ADSDAQ will NEVER serve ads to pages in Blocked Categories';
				$('categoryFill').innerHTML = CatHTMLbuild;
				return;				
			}
			if(parsesubCategories[i][c] != mainCategories[i]){
				log(parsesubCategories[i][c]);
				log(mainCategories[i]);
				CatHTMLbuild += parsesubCategories[i][c] +' > ';
			}
			else{
				CatHTMLbuild += '<span class="cls14 clsBold clsGreen">'+parsesubCategories[i][c]+'</span></div>';
				break;
			}
		}
		CatHTMLbuild += HTMLp3;
	}
	$('categoryFill').innerHTML = CatHTMLbuild;

}

function hidePop(popID){
	popID.style.display = 'none';
	$('divBackfade').style.display = 'none';
	PopUpresize = false;
}

function setinfoboxPos(objAction, title, content, author, atitle){
	objAction = $(objAction);

	$('infoBoxauthor').innerHTML = author;
	$('infoBoxauthorTitle').innerHTML = atitle; 
	$('infoBoxname').innerHTML = title;
	$('infoBoxcontent').innerHTML = content;
	$('infoBox').style.display = 'block';
	$('infoBox').setStyle('top',objAction.getPosition($('posRelation')).y - 130); $('infoBox').setStyle('left',objAction.getPosition($('posRelation')).x - 15);
}



var customerAdvisoryPanelcontent = {mediarefined: new Array("Media Refined","Media Refined is an online advertising agency with a focus on the future. We specialize in all aspects of online marketing with a concentration in brand marketing, performance-based campaigns, and search engine marketing. Our team is comprised of passionate, dedicated online professionals, who have a thirst for smart and innovative digital marketing campaigns.<br /><br />","http://www.mediarefined.com/"), cpmadvisors: new Array("CPM  Advisors","CPM Advisors, Inc. is a technology company that manages, optimizes and enhances advertising campaigns for online advertisers. We help advertisers buy media efficiently - we simplify and streamline the process of running campaigns online and provide easy access for advertisers to thousands of websites, ad platforms and ad networks, general interest and niche alike.<br /><br />","http://www.cpmadvisors.com/"), escalatemedia: new Array("Escalate Media","Escalate Media cultivates online communities connecting women who share a passion for intelligent conversation on diverse life topics. We are experts at growing thriving web communities and are one of the largest networks dedicated to the booming online women's market. With over 3.5 million monthly visitors, we deliver an addicting user experience and unique marketing opportunities with our engaged, targeted audience.<br /><br />","http://www.escalatemedia.com/"), badmoosemedia: new Array("Bad Moose Media","From marketing/advertising, to media buying, and relationship building.  Bad Moose Media does it all with tremendous speed and success.<br /><br />","http://www.badmoosemedia.com")}

function showInfobox(objArea, contentArray){
	if($('blueContentBox'))
		removeObj($('blueContentBox'), $('blueContentBox').parentNode);

	var createObj = newObj(contentArray);
	objArea.parentNode.appendChild(createObj);
	
	if(contentArray == 'cpmadvisors')
		$('blueContentBox').style.marginLeft = '245px';
}
function newObj(contentArray){
	var newDiv = document.createElement('div');
	newDiv.id = 'blueContentBox';

	var newChild = document.createElement('div');
	newChild.className = 'contentBox';

	var contentChild = document.createElement('div');
	contentChild.innerHTML = "<h2>"+customerAdvisoryPanelcontent[contentArray][0]+"</h2>"+"<p>"+customerAdvisoryPanelcontent[contentArray][1]+"</p>";

	if(customerAdvisoryPanelcontent[contentArray][2])
		contentChild.innerHTML += "<a target='_blank' class='link' href="+customerAdvisoryPanelcontent[contentArray][2]+">"+customerAdvisoryPanelcontent[contentArray][2]+"</a>";

	newChild.appendChild(contentChild);

	newDiv.appendChild(newChild);

	var bottomDiv = document.createElement('div');
	bottomDiv.className = 'bottomPiece';

	var closeAncor = new Element('a', {
		'href': 'javascript:void(0)',
		'class': 'close',
		'html': '[ X ]',
		'events': {
			'click': function(){
				//this.parentNode.style.display = 'none';
				removeObj(this.parentNode, this.parentNode.parentNode);
			}
		}
	});
	
	newDiv.appendChild(bottomDiv);

	newDiv.appendChild(closeAncor);
	
	return newDiv;
}

function removeObj(divName, containerName) {
  containerName.removeChild(divName);
}


function signupJump(clickedObj){
	logcatAjaxRequest('signupJump', clickedObj);
	if ( (document.cookie.length>0) ){
		var checkCookie = readCookie('affAdvCookie');
		var hubCookie = readCookie('hubspotutk');

		var cookiedLink = 'http://www.adsdaq.com/advertiser/signup.aspx'

		if(checkCookie)
			cookiedLink += '?aff='+checkCookie;
		if(checkCookie && hubCookie)
			cookiedLink += '&hubspotutk='+hubCookie;
		else if(hubCookie)
			cookiedLink += '?hubspotutk='+hubCookie;

		pageTracker._link(cookiedLink);
	}
	else{
		pageTracker._link('http://www.adsdaq.com/advertiser/signup.aspx');
	}

	
}

function howitworksJump(){
	if ( (document.cookie.length>0) ){
		var checkCookie = readCookie('affAdvCookie');
		if(checkCookie){
			var SignUpRef = 'http://exchange.contextweb.com/buyingdesk/howitworks/?aff='+checkCookie;
			window.location=SignUpRef;
		}
		else{
			window.location= 'http://exchange.contextweb.com/buyingdesk/howitworks/';
		}
	}
	else{
		window.location= 'http://exchange.contextweb.com/buyingdesk/howitworks/';
	}

	
}

var openCat = null;
var openCatlvl2 = null;
function showCat(category, lvlID){
	category = category.replace(/&amp;/,"&");
	category = category.split("> ");
	category = category[1];
	if(category){
		log(category);
		$(category).style.display = 'block';
		if(lvlID == 'lvl1'){
			$('catTop').setStyle('cursor','pointer');
			$('title').setStyle('cursor','pointer');
			$('catTitle2').innerHTML = category;
			$('lvl2').style.display = 'block';
			$('titlelvl2').innerHTML = 'All Categories > ' + category;
			openCat = category;
		}
		else if(lvlID == 'lvl2'){
			$('catTop2').setStyle('cursor','pointer');
			$('titlelvl2').setStyle('cursor','pointer');
			$('lvl3').style.display = 'block';
			$('catTitle3').innerHTML = category;
			$('titlelvl3').innerHTML = $('titlelvl2').innerHTML + ' > ' + category;
			openCatlvl2 = category;
		}
		else
			return;
	}
}

function backCategory(levelID){
	
	if(levelID == 'lvl3'){
		$('lvl3').style.display = 'none';
		$('catTop2').setStyle('cursor','default');
		$('titlelvl2').setStyle('cursor','default');
		if(openCatlvl2)
		$(openCatlvl2).style.display = 'none';
	}
	else if(levelID == 'lvl2'){
		$('lvl2').style.display = 'none';
		$('catTop').setStyle('cursor','default');
		$('title').setStyle('cursor','default');
		$(openCat).style.display = 'none';
	}
	else{
		$(openCat).style.display = 'none';
		if(openCatlvl2)
			$(openCatlvl2).style.display = 'none';
		$('lvl3').style.display = 'none';
		$('catTop2').setStyle('cursor','default');
		$('titlelvl2').setStyle('cursor','default');
		$('lvl2').style.display = 'none';
		$('catTop').setStyle('cursor','default');
		$('title').setStyle('cursor','default');
	}
}

function contactus(){
	var fname=document.getElementById('fname').value;
	var lname=document.getElementById('lname').value;
	var areacode=document.getElementById('areacode').value;
	var phonep1=document.getElementById('phonep1').value;
	var phonep2=document.getElementById('phonep2').value;
	var phoneext=document.getElementById('phoneext').value;
	var email=document.getElementById('cemail').value;
	var message = document.getElementById('cmessage').value;
	var dep = document.getElementById('dep').value;

	var poststr = "fname=" + encodeURI(fname) + "&lname=" + encodeURI(lname) + "&dp1=" + encodeURI(areacode) +"&dp2="+ encodeURI(phonep1)+"&dp3="+ encodeURI(phonep2)+"&dp4="+ encodeURI(phoneext)+"&email="+ encodeURI(email)+"&comments="+ encodeURI(message)+"&dept="+ encodeURI(dep);
	postAjaxRequest("/buyingdesk/code/contact.php",poststr, "contact-us");
}


function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(xmlHttp.responseText=="mail sent"){
			document.getElementById('PopUp_Content_Area').style.display="none";
			document.getElementById('PopUp_Content_Area_Contacted').style.display="block";
			document.getElementById('contact_button').style.display="none";
			document.getElementById('contacted_button').style.display="inline";}
		else
			alert(xmlHttp.responseText);
	}
}

function postAjaxRequest(url, parameters, call){
	xmlHttp=GetXmlHttpObject();


	if(call=="apply")
		xmlHttp.onreadystatechange = stateChange;
	else if(call=="contact-us")
		xmlHttp.onreadystatechange = stateChanged;
	else
		xmlHttp.onreadystatechange = stateChanger;

	url=url+"?sid="+Math.random();
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}

function logcatAjaxRequest(loggingObj, clickedObj){
	xmlHttp=GetXmlHttpObject();

	var r = /^(.*?)\/\/(.*?)\//;
	var shortURL = DocURL.replace(r,"");
	url = 'http://exchange.contextweb.com/buyingdesk/code/phpTrackContextualizer.php';
	catURL = catURL.replace('&',"-AMP-");
	var parameters = "URL=" + encodeURI(catURL) + "&refURL=" + encodeURI(shortURL)+ "&refObj=" + encodeURI(loggingObj);
	if(clickedObj)
		parameters += "&clickedObj=" + encodeURI(clickedObj);

	url=url+"?sid="+Math.random();
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}

function phoneinput(event, keyarea){
      var key = event.keyCode;

      if (((47 < key) && (58 > key)) || ((95 < key) && (106 > key)) || (46 == key) || (8 == key)){

            if(document.getElementById('areacode').value.length >= 3 && keyarea==1)
				if(document.getElementById('phonep1').value.length <= 2)
					document.getElementById('phonep1').focus();
				else if(document.getElementById('phonep2').value.length <= 3)
					document.getElementById('phonep2').focus();
				else
					document.getElementById('phoneext').focus();
			if(document.getElementById('phonep1').value.length >= 3 && keyarea==2)
				if(document.getElementById('phonep2').value.length <= 3)
					document.getElementById('phonep2').focus();
				else
					document.getElementById('phoneext').focus();
			if(document.getElementById('phonep2').value.length >= 4 && keyarea==3)
				document.getElementById('phoneext').focus();

      }
      else{
            if (window.event) {

                  window.event.returnValue = null;
            }
            else{
                  event.preventDefault();
            }
      } 
}

function hidecontact(){
	$('divBackfade').style.display = 'none';
	$('contactUs').style.display = 'none';
	PopUpresize = false;

}

function showcontact(){
	if(!$('divBackfade')){
		BackFadeAppendBackfadeDiv();
	}
	$('divBackfade').style.display = 'block';
	$('contactUs').style.display = 'block';
	PopUpresize = true;
}

// Script for MainNav

var setActiveURL = '';
var setActiveImg = '';

window.addEvent('domready', function() {
	if($('img1')){

		$('img1').addEvent('mouseover', function(){
			imgOn('img1');
		});
		$('img1').addEvent('mouseout', function(){
			imgOff('img1');
		});

		var img2onFunction = function(){imgOn('img2');}
		$('img2').addEvent('mouseover', img2onFunction);

		$('img2').addEvent('mouseover', function(){
			$('howitworksDropdown').style.display = 'block';
			addElement('howitworksDropdown','img2');					
		});
			$('img2a').addEvent('mouseover', function(){
				imgOn('img2a');
			});
			$('img2a').addEvent('mouseout', function(){
				imgOff('img2a');
			});
		$('img3').addEvent('mouseover', function(){
			imgOn('img3');
		}); 
		$('img3').addEvent('mouseout', function(){
			imgOff('img3');
		});
		$('img4').addEvent('mouseover', function(){
			imgOn('img4');
		});
		$('img4').addEvent('mouseout', function(){
			imgOff('img4');
		});

		var img6onFunction = function(){imgOn('img6')};
		$('img6').addEvent('mouseover', img6onFunction)

		$('img6').addEvent('mouseover', function(){
			$('videoDropdown').style.display = 'block';
			addElement('videoDropdown','img6');
		});
			$('img6a').addEvent('mouseover', function(){
				imgOn('img6a');
			});
			$('img6a').addEvent('mouseout', function(){
				imgOff('img6a');
			});
			$('img6b').addEvent('mouseover', function(){
				imgOn('img6b');
			});
			$('img6b').addEvent('mouseout', function(){
				imgOff('img6b');
			});
		$('signUp').addEvent('mouseover', function(){
			imgOn('signUp');
		});
		$('signUp').addEvent('mouseout', function(){
			imgOff('signUp');
		});
		

		switch (urlSet[1]){
			case '/':
				$('img1').removeEvents();
				break;
			case '/howitworks/':
				$('img2').removeEvent('mouseover',img2onFunction);
				$('img2').removeEvents('mouseout');
				setActiveURL = '/howitworks/';
				setActiveImg = 'img2';
				break;
			case '/howitworks/adsdaq_categories/':
				$('img2').removeEvent('mouseover',img2onFunction);
				$('img2a').removeEvents();
				setActiveURL = '/howitworks/adsdaq_categories/';
				setActiveImg = 'img2';
				break;
			case '/community/':
				$('img3').removeEvents();
				break;
			case '/viewdemos/':
				$('img6').removeEvent('mouseover',img6onFunction);
				$('img6').removeEvents('mouseout');
				setActiveURL = '/viewdemos/';
				setActiveImg = 'img6';
				break;
			case '/viewdemos/educationaldemos/':
				$('img6').removeEvent('mouseover',img6onFunction);
				$('img6a').removeEvents();
				setActiveURL = '/viewdemos/educationaldemos/';
				setActiveImg = 'img6';
				break;
			case '/viewdemos/easydemo/':
				$('img6').removeEvent('mouseover',img6onFunction);
				$('img6b').removeEvents();
				setActiveURL = '/viewdemos/easydemo/';
				setActiveImg = 'img6';
				break;
			case '/faq/':
				$('img4').removeEvents();
				break;
		}
	}

});

//addElement Javascript Function
function addElement(idname, imgname) {
	var ni = $(idname).parentNode;
	var newDiv = document.createElement('div');
	newDiv.setAttribute('id','hideDropdown');
	ni.appendChild(newDiv);
	$('hideDropdown').style.display = 'block';
	$('hideDropdown').style.zIndex = '3';
	$('hideDropdown').style.top = '-200px';
	$('hideDropdown').style.left = '-200px';

	$('hideDropdown').addEvent('mouseover', function(){
		if(imgname != setActiveImg)
			imgOff(imgname);
		$(idname).style.display = 'none';
		removeElement('hideDropdown',idname);
	});
}

//removeElement JavaScript Function

function removeElement(divName, containerName) {
  var d = $(containerName).parentNode;
  var olddiv = $(divName);
  d.removeChild(olddiv);
}