
function PopWindow424330()
{ 
window.open('inclick_password.php','password_finder424330','width=400,height=400,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=50,left=50'); 
}
function PopWindow793028()
{
	window.open('inclick_keyword.php','keyword793028','width=300,height=500,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,top=25,left=325');
}
function PopWindow507460()
{
	window.open('inclick_viewbids.php','bids507460','width=300,height=500,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,top=25,left=25');
}


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
	if (window.event&&event.srcElement.value.length>=maxlength)
	return false
	else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
		var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
		if (pressedkey.test(String.fromCharCode(e.which)))
		e.stopPropagation()
	}
	return true;
}

function countlimit(maxlength,e,placeholder){
	var theform=eval(placeholder)
	var lengthleft=maxlength-theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder)){
		if (lengthleft<0)
		theform.value=theform.value.substring(0,maxlength)
		placeholderobj.innerHTML=lengthleft
	}
}


function displaylimit(theform,thelimit){
	var limit_text='<small><b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining</small>'
	if (document.all||ns6)
	document.write(limit_text)
	if (document.all){
		eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
		eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
		document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
	}
}




function move(fbox, tbox) {
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	for(i=0; i<tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length
	for(i=0; i<fbox.options.length; i++) {
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
		} else {
			arrFbox[fLength] = fbox.options[i].text;
			fLength++;
		}
	}
	
	arrFbox.sort();
	arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	var c;
	for(c=0; c<arrFbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrFbox[c]];
		no.text = arrFbox[c];
		fbox[c] = no;
	}
	for(c=0; c<arrTbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrTbox[c]];
		no.text = arrTbox[c];
		tbox[c] = no;
	}
}

function sortListBox(listbox)
{
	var sort_array = new Array();
	var lookup_array = new Array();
	var x;
	
	for (x = 0; x < listbox.options.length; x++)
	{
		sort_array[x] = listbox.options[x].text;
		lookup_array[listbox.options[x].text] = listbox.options[x].value;
	}
	
	sort_array.sort();
	listbox.length = 0;
	
	for (x = 0; x < sort_array.length; x++)
	{
		var new_option = new Option();
		new_option.value = lookup_array[sort_array[x]];
		new_option.text = sort_array[x];
		listbox[x] = new_option;
	}
}

function selectAll(box) {
	for(var i=0; i<box.length; i++) {
		box[i].selected = true;
	}
}
//CONFIRMATION BOX
function confirm_prompt(text,link) {
    if (confirm(text)) {
    	window.location = link;
    }
}

var headerjs_set = 1;

//CATEGORIZED CHANNELS
function getCookie(name) {
  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));
}
function showHideSwitch (theid) {
  if (document.getElementById) {
    var switch_id = document.getElementById(theid);
    var imgid = theid+'Button';
    var button_id = document.getElementById(imgid);
    if (menus_status_array[theid] != 'show') {
      button_id.setAttribute ('src', img_close);
      switch_id.className = 'showSwitch';
	  menus_status_array[theid] = 'show';
	  document.cookie = theid+'=show';
    }else{
      button_id.setAttribute ('src', img_open);
      switch_id.className = 'hideSwitch';
	  menus_status_array[theid] = 'hide';
	  document.cookie = theid+'=hide';
    }
  }
}
function resetMenu () { // read cookies and set menus to last visited state
  if (document.getElementById) {
    for (var i=0; i<menus_array.length; i++) {
      var idname = menus_array[i];
      var switch_id = document.getElementById(idname);
      var imgid = idname+'Button';
      var button_id = document.getElementById(imgid);
      if (getCookie(idname) == 'show') {
	    button_id.setAttribute ('src', img_close);
        switch_id.className = 'showSwitch';
	    menus_status_array [idname] = 'show';
	  }else{
	    button_id.setAttribute ('src', img_open);
        switch_id.className = 'hideSwitch';
	    menus_status_array [idname] = 'hide';
	  }
    }
  }
}
//document_write("<link rel='stylesheet' type='text/css' href='inclick_style.css' />");

// SEARCHABLE STEP 3, CHANNEL SELECTION
function loadExternal(url) {
  if ( window.frames['buffer'] ) {
    window.frames['buffer'].location = url;
    var lyr = document.getElementById? document.getElementById('display'): document.all? document.all['display']: null;
    if ( lyr && typeof lyr.innerHTML != "undefined" ) {
      lyr.innerHTML = '<br><br><br><br><center><img src="images/processing.gif" alt=""></center>';
    }
    return false;
  } 
  return true; // other browsers follow link
}

// called when documents loaded into iframe (from their body's onload attribute)
function displayExternal() {
  var lyr = document.getElementById? document.getElementById('display'): document.all? document.all['display']: null;
    if ( window.frames['buffer'] && lyr && typeof lyr.innerHTML != "undefined" ) {
      lyr.innerHTML = window.frames['buffer'].document.body.innerHTML;
    }
    
}

function updateRegionStatus(form)
{
	var x = 0;
	var all_regions = document.getElementById("region_scope_all")
	var specific_regions = document.getElementById("region_scope_specific");
	
	if (all_regions.checked && form.elements["action_vars[region][]"].options.length > 0)
	{
		all_regions.checked = false;
		specific_regions.checked = true;
	}
	else if (specific_regions.checked && form.elements["action_vars[region][]"].options.length == 0)
	{
		all_regions.checked = true;
		specific_regions.checked = false;
	}
}

function checkRegionsOnSubmit(form)
{
	var all_regions = document.getElementById("region_scope_all")
	var specific_regions = document.getElementById("region_scope_specific");
		
	if (all_regions.checked && form.elements["action_vars[region][]"].options.length > 0)
	{
		if (confirm("You have specified regions but you have selected 'All of the United States'.  Are you sure you would like to continue?"))
		{
			form.elements["action_vars[region][]"].options.length = 0;
			return true;
		}
		return false;
	}
	return true;
}

function updateKeywordStatus(form)
{
	var all_keywords = document.getElementById("keyword_scope_all");
	var specific_keywords = document.getElementById("keyword_scope_specific");
	
	var has_keywords = false;
	
	if (form.ad_keywords.value != "" && form.ad_keywords.value.length > 0)
	{
		has_keywords = true;
	}
	
//	if (all_keywords.checked && has_keywords)
	if (has_keywords)
	{
		specific_keywords.checked = true;
		all_keywords.checked = false;
	}
	//else if (specific_keywords.checked && !has_keywords)
	else
	{
		all_keywords.checked = true;
		specific_keywords.checked = false;
	}
}


function checkKeywordsOnSubmit(form)
{
	var all_keywords = document.getElementById("keyword_scope_all");
	var specific_keywords = document.getElementById("keyword_scope_specific");
		
	if (all_keywords.checked && form.ad_keywords.value != "")
	{
		if (confirm("You have specified keywords but you have selected 'Any Keyword'.  Are you sure you would like to continue?"))
		{
			form.ad_keywords.value = "";
			return true;
		}
		return false;
	}
	return true;
}

 var time = null 
 function logout() { 
 	window.location = 'client.php?action=logout&logout_error=11'; 
 } 
  function afterpayment() { 
 	window.location = 'client.php'; 
 } 
 
 function showHelpText(inCaption, inMessage, useCSS)
 {
 	if (!useCSS)
 	{
	 	if (inCaption != "")
	 	{
	 		return overlib(inMessage, CAPTION, inCaption, BGCOLOR, '#00AEEF', FGCOLOR, '#D1E39B');
	 	}
	 	return overlib(inMessage);
 	}
 	if (inCaption != "")
 	{
 		return overlib(inMessage, CAPTION, inCaption, BGCOLOR, '#00AEEF', FGCOLOR, '#D1E39B', CSSCLASS);
 	}
 	return overlib(inMessage);
 	
 }
 
  function showIPText(inCaption, inMessage)
 {
 	if (inCaption != "")
 	{
 		return overlib(inMessage, CAPTION, inCaption, BGCOLOR, '#666666', FGCOLOR, '#FFFFFF',WIDTH, '250', OFFSETY, 10, BELOW, DELAY, 750, STICKY, MOUSEOFF);
 	}
 	return overlib(inMessage);
 }
 
 function enforceMaxLength(inField, maxLength, fieldEvent)
 {
	var key;
	var keychar;
	
	if (window.event)
	{
	   key = window.event.keyCode;
	}
	else if (fieldEvent)
	{
	   key = fieldEvent.which;
	}
	else
	{
	   return true;
	}
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	return true;
		
	if (inField.value.length >= maxLength)
	{
		return false;
	}
	return true;
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 //Custom JavaScript Functions by Shawn Olson
//Copyright 2006
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
//*******************************************

	function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
    }
	
	function changecss(theClass,element,value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	 var cssRules;
	 if (document.all) {
	  cssRules = 'rules';
	 }
	 else if (document.getElementById) {
	  cssRules = 'cssRules';
	 }
	 for (var S = 0; S < document.styleSheets.length; S++){
	  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
	   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	    document.styleSheets[S][cssRules][R].style[element] = value;
	   }
	  }
	 }	
	}
	
	function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }
	
function checkUncheckSome(controller,theElements) {
	//Programmed by Shawn Olson
	//Copyright (c) 2006
	//Permission to use this function provided that it always includes this credit text
	//  http://www.shawnolson.net
	//Find more JavaScripts at http://www.shawnolson.net/topics/Javascript/
	
	

	
     var formElements = theElements.split(',');
	 var theController = document.getElementById(controller);
	 for(var z=0; z<formElements.length;z++){
	  theItem = document.getElementById(formElements[z]);
	  if(theItem){
	  if(theItem.type){
        if(theItem.type == 'checkbox' && theItem.id != theController.id){
	     theItem.checked = theController.checked;
	    }
	  } else {

	    var nextArray = '';
	     for(var x=0;x <theItem.childNodes.length;x++){
	      if(theItem.childNodes[x]){
	        if (theItem.childNodes[x].id){
	          nextArray += theItem.childNodes[x].id+',';
		    }
	      }
	     }
	     checkUncheckSome(controller,nextArray);
	   
	   }
	  
	  }
     }
    }
	
	
	
	
	function changeImgSize(objectId,newWidth,newHeight) {
	  imgString = 'theImg = document.getElementById("'+objectId+'")';
	  eval(imgString);
	  oldWidth = theImg.width;
	  oldHeight = theImg.height;
	  if(newWidth>0){
	   theImg.width = newWidth;
	  } 
	  if(newHeight>0){
	   theImg.height = newHeight;
	  } 
	
	}
	
	function changeColor(theObj,newColor){
	  eval('var theObject = document.getElementById("'+theObj+'")');
	  if(theObject.style.backgroundColor==null){theBG='white';}else{theBG=theObject.style.backgroundColor;}
	  if(theObject.style.color==null){theColor='black';}else{theColor=theObject.style.color;}
	  //alert(theObject.style.color+' '+theObject.style.backgroundColor);
      switch(theColor){
	    case newColor:
		  switch(theBG){
			case 'white':
		      theObject.style.color = 'black';
		    break;
			case 'black':
			  theObject.style.color = 'white';
			  break;
			default:
			  theObject.style.color = 'black';
			  break;
		  }
		  break;
	    default:
		  theObject.style.color = newColor;
		  break;
	  }
	}
	
	
	// CURRENCY FORMATTING
	
	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '' + num + '.' + cents);
	}
	
	function updateHiddenFieldAndSubmitForm(element_id, new_value)
	{
		var hidden_field = document.getElementById(element_id);
		if (hidden_field != null)
		{
			hidden_field.value = new_value;
			hidden_field.form.submit();
		}
	}
	function updateHiddenField(element_id, new_value)
	{
		var hidden_field = document.getElementById(element_id);
		if (hidden_field != null)
		{
			hidden_field.value = new_value;
			//hidden_field.form.submit();
		}
	}

	function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function getReportEventTarget(inEvent)
{
	if(!inEvent) inEvent = window.event;
	var target = inEvent.target? inEvent.target: inEvent.srcElement;
	
	while(target && target.tagName && target.tagName.toLowerCase()!="tr")
	{
		if (target && target.tagName.toLowerCase() == "td")
		{
			if (target.colSpan > 2)
			{
				target = null;
			}
		}
		if (target)
		{
			target = target.parentNode;
		}
	}
	return target;
}

function handleReportMouseOver(inEvent)
{
	var target = getReportEventTarget(inEvent);
	if (!target)
	{
		return;
	}

	target.oldClassName = target.className;
	target.className = "focused";
	if (target.style.backgroundColor)
	{
		target.oldBackgroundStyleColor = target.style.backgroundColor;
		target.style.backgroundColor = "";
	}
}

function handleReportMouseOut(inEvent)
{
	var target = getReportEventTarget(inEvent);
	
	if (!target)
	{
		return;
	}
	
	if (target.oldClassName != null)
	{
		target.className = target.oldClassName;
		target.oldClassName = null;
	}
	if (target.oldBackgroundColor != null)
	{
		target.backgroundColor = target.oldBackgroundColor;
		target.oldBackgroundColor = null;
	}
	if (target.oldBackgroundStyleColor != null)
	{
		target.style.backgroundColor = target.oldBackgroundStyleColor;
		target.oldBackgroundStyleColor = null;
	}
}

function initializeReportRows()
{
	nodeList = document.getElementsByTagName("table");
	var x;
	for (x = 0; x < nodeList.length; x++)
	{
		if (nodeList[x].className.indexOf("report") != -1 || nodeList[x].className.indexOf("feed_description") != -1)
		{
			childNodeList = nodeList[x].getElementsByTagName("tr");
			var dataStarted = false;
			var alternateRow = false;
			var alternateSubRow = false;
			
			for (y = 0; y < childNodeList.length; y++)
			{
				rowNode = childNodeList[y];
				
				if (rowNode.className.indexOf("report_data_row") != -1 || rowNode.className.indexOf("report_data_sub_row") != -1)
				{
					dataStarted = true;
					if (rowNode.className.indexOf("report_data_row") != -1)
					{
						if (alternateRow)
						{
							rowNode.className += " alternate_row";
							alternateRow = false;
						}						
						else
						{
							alternateRow = true;
						}
						alternateSubRow = false; //Reset the subrow setting
					}
					else
					{
						if (alternateSubRow)
						{
							rowNode.className += " alternate_row";
							alternateSubRow = false;
						}
						else
						{
							alternateSubRow = true;
						}
					}

					if (rowNode.addEventListener)
					{
						rowNode.addEventListener('mouseover', handleReportMouseOver, false);					
						rowNode.addEventListener('mouseout', handleReportMouseOut, false);						
					}
					else if (nodeList[x].attachEvent)
					{
						rowNode.attachEvent('onmouseover', handleReportMouseOver);					
						rowNode.attachEvent('onmouseout', handleReportMouseOut);
					}
					else
					{
						rowNode.onmouseover = handleReportMouseOver;
						rowNode.onmouseout = handleReportMouseOut;
					}

				}
				else
				{
					dataStarted = false;
				}
			}
		}			
	}
}

function showCampaignEditWindow(campaignID, campaignType, showCosts, showSettings, editAction)
{
	baseURL = "client.php?pageid=ad&camp_id=" + campaignID + "&campaign_type=" + campaignType + "&subpid=";
	var inMessage = "";
	inMessage += "<p><a href=\"" + baseURL + "edit&campaign_action=" + editAction + "\">Campaign Details</a></p>";
	if (showCosts)
	{
		inMessage += "<p><a href=\"" + baseURL + "costs\">CPC and Budget</a></p>";
	}
	if (showSettings)
	{
		inMessage += "<p><a href=\"" + baseURL + "settings\">Delivery Settings</a></p>";
	}
	else
	{
		inMessage += "<p><a href=\"" + baseURL + "settings\">Edit Date Range</a></p>";		
	}
	
 	return overlib(inMessage, CAPTION, 'Edit Campaign', WIDTH, 150, OFFSETY, 5, BELOW, DELAY, 500, STICKY, MOUSEOFF, CSSCLASS, TEXTSIZE, '12px', CAPTIONSIZE, '12px', NOCLOSE);
}

function showCampaignReportsWindow(campaignID, showKeyword)
{
	baseURL = "client.php?pageid=reports&campaign_id=" + campaignID + "&subpid=ads&report_type=";
	var inMessage = "";
	inMessage += "<p><a href=\"" + baseURL + "day\">Daily Report</a></p>";
	inMessage += "<p><a href=\"" + baseURL + "campaign\">Campaign Report</a></p>";
	if (showKeyword)
	{
		inMessage += "<p><a href=\"" + baseURL + "keyword\">Keyword Report</a></p>";
	}
	
 	return overlib(inMessage, CAPTION, 'Reports', WIDTH, 150, OFFSETY, 5, BELOW, DELAY, 500, STICKY, MOUSEOFF, CSSCLASS, TEXTSIZE, '12px', CAPTIONSIZE, '12px', NOCLOSE);
}

