var use_gebi=false, use_css=false, use_layers=false;
if (document.getElementById) { use_gebi=true; }
if (document.all) { use_css=true; }
if (document.layers) { use_layers=true; } 

var catNAval = "No Category";
var urlErrMsg = "** ENTER URL";
var extErrMsg = "** .png .jpg .jpeg .gif .swf only";

var currency_symbol = "$";

if (ordering_cur == "AUD") {
	currency_symbol = "$";
} else if (ordering_cur == "CAD") {
	currency_symbol = "$";
} else if (ordering_cur == "EUR") {
	currency_symbol = "\u20ac";
} else if (ordering_cur == "GBP") {
	currency_symbol = "\u00a3";
} else if (ordering_cur == "JPY") {
	currency_symbol = "\u00a5";
} else if (ordering_cur == "USD") {
	currency_symbol = "$";
} else if (ordering_cur == "NZD") {
	currency_symbol = "$";
} else if (ordering_cur == "CHF") {
	currency_symbol = ordering_cur;
} else if (ordering_cur == "HKD") {
	currency_symbol = "$";
} else if (ordering_cur == "SGD") {
	currency_symbol = "$";
} else if (ordering_cur == "SEK") {
	currency_symbol = "kr";
} else if (ordering_cur == "DKK") {
	currency_symbol = "kr";
} else if (ordering_cur == "PLN") {
	currency_symbol = "\u007a\u0142";
} else if (ordering_cur == "NOK") {
	currency_symbol = "kr";
} else if (ordering_cur == "HUF") {
	currency_symbol = "Ft";
} else if (ordering_cur == "CZK") {
	currency_symbol = "\u004b\u010d";
} else if (ordering_cur == "ILS") {
	currency_symbol = "\u20aa";
} else if (ordering_cur == "MXN") {
	currency_symbol = "$"; 
}

function OSF_doAdType() {
	var adtypefld, imgSizerowfld, imglocfld, hasPopsfld, hasSoundfld, typeLabelfld, selCountryfld, vistdfld, cofld, totfld;
	if (use_gebi) {
		adtypefld = document.getElementById("OSF_adtype");
		imgSizerowfld = document.getElementById("OSF_imgSizerow");
		imglocfld = document.getElementById("OSF_imgloc");
		hasPopsfld = document.getElementById("OSF_hasPops");
		hasSoundfld = document.getElementById("OSF_hasSound");
		typeLabelfld = document.getElementById("OSF_typeLabel");
		selCountryfld = document.getElementById("OSF_selCountry");
		vistdfld = document.getElementById("OSF_visittd");
		cofld = document.getElementById("OSF_co");
		totfld = document.getElementById("OSF_xtotal");
	} else if (use_css) {
		adtypefld = document.all["OSF_adtype"];
		imgSizerowfld = document.all["OSF_imgSizerow"];
		imglocfld = document.all["OSF_imgloc"];
		hasPopsfld = document.all["OSF_hasPops"];
		hasSoundfld = document.all["OSF_hasSound"];
		typeLabelfld = document.all["OSF_typeLabel"];
		selCountryfld = document.all["OSF_co"];
		visnofld = document.all["OSF_visitorno"];
		cofld = document.all["OSF_co"];
		totfld = document.all["OSF_xtotal"];
	} else if (use_layers) {
		adtypefld = document.layers["OSF_adtype"];
		imgSizerowfld = document.layers["OSF_imgSizerow"];
		imglocfld = document.layers["OSF_imgloc"];
		hasPopsfld = document.layers["OSF_hasPops"];
		hasSoundfld = document.layers["OSF_hasSound"];
		typeLabelfld = document.layers["OSF_typeLabel"];
		selCountryfld = document.layers["OSF_selCountry"];
		vistdfld = document.layers["OSF_visittd"];
		cofld = document.layers["OSF_co"];
		totfld = document.layers["OSF_xtotal"];
	}

	if (adtypefld.value == "traffic") {
		imgSizerowfld.className = "OSF_HideimgOptions";
		imglocfld.className = "OSF_HideimgOptions";
		hasPopsfld.className = "OSF_ShowimgOptions";
		hasSoundfld.className = "OSF_ShowimgOptions";
		typeLabelfld.innerHTML = "Visitors: ";
		selCountryfld.innerHTML = "<select name='OSF_co' class='OSF_xSELECT' onChange='OSF_setPrice()\;' id='OSF_co'>"+
			"<option value='0' selected>Select ---------"+
			"<optgroup label='By Region:'>"+
			"<option value='United States'>United States"+
			"<option value='United Kingdom'>United Kingdom"+
			"<option value='Canada'>Canada"+
			"<option value='North America'>North America"+
			"<option value='Europe'>Europe"+
			"<option value='Australia'>Australia"+
			"<option value='Worldwide'>Worldwide"+
			"<option value='Bulk'>Bulk"+
			"<optgroup label='By Language:'>"+
			"<option value='English'>English"+
			"</select> &nbsp;<a href='javascript:void(0)\;' class='OSF_xtestlink' id='OSF_OStrafficnote' OnMouseOver=\"xOSGeonotes('OSF_co',document.getElementById('OSF_co').value,0,0,1);\" OnMouseOut=\"xOSGeonotes('OSF_co','',100,0);\">(?)</a>";
		
		vistdfld.innerHTML = "<select class='OSF_xSELECT' name='OSF_visitorno' id='OSF_visitorno' onChange='OSF_setPrice();'>"+
					build_vis_amounts +
					"</select>";
					
		totfld.value = "0.00";
	} else {
		imgSizerowfld.className = "OSF_ShowimgOptions";
		imglocfld.className = "OSF_ShowimgOptions";
		hasPopsfld.className = "OSF_HideimgOptions";
		hasSoundfld.className = "OSF_HideimgOptions";
		typeLabelfld.innerHTML = "Impressions: ";
		selCountryfld.innerHTML = "<select name='OSF_co' class='OSF_xSELECT' onChange='OSF_setPrice()\;' id='OSF_co'>"+
			"<option value='0' selected>Select ---------"+
			"<optgroup label='By Region:'>"+
			"<option value='United States'>United States"+
			"<option value='United Kingdom'>United Kingdom"+
			"<option value='Canada'>Canada"+
			"<option value='North America'>North America"+
			"<option value='Europe'>Europe"+
			"<option value='Australia'>Australia"+
			"<option value='Worldwide'>Worldwide"+
			"<optgroup label='By Language:'>"+
			"<option value='English'>English"+
			"</select> &nbsp;<a href='javascript:void(0)\;' class='OSF_xtestlink' id='OSF_OStrafficnote' OnMouseOver=\"xOSGeonotes('OSF_co',document.getElementById('OSF_co').value,0,0,2);\" OnMouseOut=\"xOSGeonotes('OSF_co','',100,0);\">(?)</a>";

		vistdfld.innerHTML = "<select class='OSF_xSELECT' name='OSF_visitorno' id='OSF_visitorno' onChange='OSF_setPrice();'>"+
					build_impression_amounts +
					"</select>";
		totfld.value = "0.00";
	}
}

function OSF_tster_image(linkid1, linkid2, val,size){
	var setSize = false;
	var xoffset = 0, yoffset = 0;
	var table_w, table_h, img_w, img_h;
	var uselinkid = linkid1;

	if (size == "728x90") {
		table_w = 755;
		table_h = 99;
		img_w = 728;
		img_h = 90;
		xoffset = 10;
		yoffset = 5;
		uselinkid = linkid2;
		setSize = true;
	}	  
	else if (size == "468x60") {
		table_w = 515;
		table_h = 66;
		img_w = 468;
		img_h = 60;
		xoffset = 10;
		yoffset = 5;
		uselinkid = linkid2;
		setSize = true;
	}
	else if (size == "120x600") {
		table_w = 126;
		table_h = 615;
		img_w = 120;
		img_h = 600;
		setSize = true;
	}
	else if (size == "160x600") {
		table_w = 168;
		table_h = 615;
		img_w = 160;
		img_h = 600;
		setSize = true;
	}
	else if (size == "300x250") {
		table_w = 315;
		table_h = 265;
		img_w = 300;
		img_h = 250;
		setSize = true;
	}
	else {
		if (use_gebi) {
			sizefld = document.getElementById('OSF_size');
		} else if (use_css) {
			sizefld = document.all['OSF_size'];
		} else if (use_layers) {
			sizefld = document.layers['OSF_size'];
		}
	
		sizefld.focus();
		return 0;
	}
	var testDiv, testImg, testtd;
	if (use_gebi) {
		testDiv = document.getElementById('OSF_imgTestDiv');
		testImg = document.getElementById('OSF_imgTest');
		testtd = document.getElementById('OSF_imgTesttd');
	} else if (use_css) {
		testDiv = document.all["OSF_imgTestDiv"];
		testImg = document.all["OSF_imgTest"];
		testtd = document.all["OSF_imgTesttd"];
	} else if (use_layers) {
		testDiv = document.layers["OSF_imgTestDiv"];
		testImg = document.layers["OSF_imgTest"];
		testtd = document.layers["OSF_imgTesttd"];
	}

	var where_at = getAnchorPositionXY(uselinkid);
	testDiv.style.left = where_at.x + xoffset +"px";
	testDiv.style.top = where_at.y + yoffset +"px";
	
	testImg.src = val + "?" + Math.random();
	if (setSize) {
		testImg.width = img_w;
		testImg.height = img_h;
		testtd.width = table_w;
		testtd.height = table_h;	
	}
}


function OSF_tster_external(linkid,frmType) {
	var where_at = getAnchorPositionXY(linkid);
	var set_h_f = where_at.y + 35;

	var clienturl = "";
	if (frmType == 1) {
		var xurlfld;
		if (use_gebi) {
			xurlfld = document.getElementById('OSF_xurl');
		} else if (use_css) {
			xurlfld = document.all['OSF_xurl'];
		} else if (use_layers) {
			xurlfld = document.layers['OSF_xurl'];
		}
		clienturl = xurlfld.value;
	}
	var set_w_f = screen.availWidth-(screen.availWidth*.5);
	var set_h = screen.availHeight-(screen.availHeight*.5);
	var set_center = (screen.availWidth-set_w_f)/2;
	var testurl_win1 = window.open(clienturl, "", "titlebar=0,toolbar=0,location=1,menubar=0,scrollbars=1,resizable=1,channelmode=0,directories=0,status=0,left=" + set_center + ",top=" + set_h_f + ",width=" + set_w_f + ",height=" + set_h + "\"");
}

function xOSnotes(lid,msg,xos,yos) {
	var msgDiv;
	if (use_gebi) {
		msgDiv = document.getElementById('OSF_xOSmsgDIV');
	} else if (use_css) {
		msgDiv = document.all['OSF_xOSmsgDIV'];
	} else if (use_layers) {
		msgDiv = document.layers['OSF_xOSmsgDIV'];
	}

	msgDiv.className ="OSF_xOSNotes";
	var myTopMargin = msgDiv.style.top;
	var NPTopMargin = myTopMargin.indexOf("-");
	if (NPTopMargin < 0) {
		msgDiv.style.top = -300+"px";
	}else{
		var where_at = getAnchorPositionXY(lid);
		var set_center = where_at.x + xos;
		var set_h_f = where_at.y + yos;

		msgDiv.innerHTML = msg;
		msgDiv.style.left = set_center+"px";
		msgDiv.style.top = set_h_f+"px";
	}

}

function xOSAdtypenotes(lid,val,xos,yos) {
	var msgDiv;
	if (use_gebi) {
		msgDiv = document.getElementById('OSF_xOSmsgDIV');
	} else if (use_css) {
		msgDiv = document.all['OSF_xOSmsgDIV'];
	} else if (use_layers) {
		msgDiv = document.layers['OSF_xOSmsgDIV'];
	}
	msgDiv.className ="OSF_xOSgeoNotes";

	var msg;
	var defaultMsg = "Select an adtype to see a description";

	if(val == "traffic"){
		msg = "<b>Guidelines:</b> Website must not contain adult content or scripting that alters a user's browser.";
	}else if(val == "banner"){
		msg = "Banners can be in gif, jpg, jpeg, png, or swf format and up to 40k in size. File will be downloaded from your URL and served from our image servers. <b>Guidelines:</b> Website must not contain adult content. Image must not be adult or contain automatically playing sound (swf).";
	} else {
		msg = defaultMsg;
	}

	var myTopMargin = msgDiv.style.top;
	var NPTopMargin = myTopMargin.indexOf("-");
	if (NPTopMargin < 0) {
		msgDiv.style.top = -300+"px";
	}else{
		var where_at = getAnchorPositionXY(lid);
		var set_center = where_at.x + xos;
		var set_h_f = where_at.y + yos;

		msgDiv.innerHTML = msg;
		msgDiv.style.left = set_center+"px";
		msgDiv.style.top = set_h_f+"px";
	}

}

function xOSGeonotes(lid,val,xos,yos,adtype) {
	var msgDiv;
	if (use_gebi) {
		msgDiv = document.getElementById('OSF_xOSmsgDIV');
	} else if (use_css) {
		msgDiv = document.all['OSF_xOSmsgDIV'];
	} else if (use_layers) {
		msgDiv = document.layers['OSF_xOSmsgDIV'];
	}
	msgDiv.className ="OSF_xOSgeoNotes";

	var msg;
	var defaultMsg = "Select a geo-target to see a description";

	if (adtype==1) {
		if(val == "English"){
			msg = "All visitors will be <b>English</b> speaking";
		}else if(val == "Bulk"){
			msg = "<b>Bulk</b> is the same as Worldwide (any country), however, it is comprised of remnant network inventory and is susceptible to slower delivery rates";
		}else if(val == "Worldwide"){
			msg = "Visitors will come from countries <b>worldwide</b>";
		}else if(val == "Australia"){
			msg = "All visitors will come from <b>Australia</b>";
		}else if(val == "Europe"){
			msg = "All visitors will come from <b>European</b> countries";
		}else if(val == "North America"){
			msg = "All visitors will come from the <b>United States</b> and <b>Canada</b>";
		}else if(val == "Canada"){
			msg = "All visitors will come from <b>Canada</b>";
		}else if(val == "United Kingdom"){
			msg = "All visitors will come from the <b>United Kingdom</b>";
		}else if(val == "United States"){
			msg = "All visitors will come from the <b>United States</b>";
		} else {
			msg = defaultMsg;
		}
	}else{

		if(val == "English"){
			msg = "Target an <b>English</b> speaking audience";
		}else if(val == "Worldwide"){
			msg = "Target audiences from <b>all countries</b>";
		}else if(val == "Australia"){
			msg = "Target an <b>Australian</b> audience";
		}else if(val == "Europe"){
			msg = "Target audiences from <b>European</b> countries";
		}else if(val == "North America"){
			msg = "Target audiences from the <b>United States</b> and <b>Canada</b>";
		}else if(val == "Canada"){
			msg = "Target a <b>Canadian</b> audience";
		}else if(val == "United Kingdom"){
			msg = "Target a <b>UK</b> audience";
		}else if(val == "United States"){
			msg = "Target a <b>US</b> audience";
		} else {
			msg = defaultMsg;
		}
	}

	var myTopMargin = msgDiv.style.top;
	var NPTopMargin = myTopMargin.indexOf("-");
	if (NPTopMargin < 0) {
		msgDiv.style.top = -300+"px";
	}else{
		var where_at = getAnchorPositionXY(lid);
		var set_center = where_at.x + xos;
		var set_h_f = where_at.y + yos;

		msgDiv.innerHTML = msg;
		msgDiv.style.left = set_center+"px";
		msgDiv.style.top = set_h_f+"px";
	}
}

function OSF_getPrice(regionName, bannerType) {
	var price = 0.00;

	if (bannerType == "") {
		if (regionName == "United States") {
			price = us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = uk_cpm;
		}
		else if (regionName == "Canada") {
			price = ca_cpm;
		}
		else if (regionName == "North America") {
			price = na_cpm;
		}
		else if (regionName == "Europe") {
			price = eu_cpm;
		}
		else if (regionName == "Australia") {
			price = au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = untar_cpm;
		}
		else if (regionName == "Bulk") {
			price = bulk_cpm;
		}
		else if (regionName == "English") {
			price = en_cpm;
		}
	}
	else if (bannerType == "468x60") {
		if (regionName == "United States") {
			price = fou_us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = fou_uk_cpm;
		}
		else if (regionName == "Canada") {
			price = fou_ca_cpm;
		}
		else if (regionName == "North America") {
			price = fou_na_cpm;
		}
		else if (regionName == "Europe") {
			price = fou_eu_cpm;
		}
		else if (regionName == "Australia") {
			price = fou_au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = fou_untar_cpm;
		}
		else if (regionName == "English") {
			price = fou_en_cpm;
		}
	}
	else if (bannerType == "728x90") {
		if (regionName == "United States") {
			price = sev_us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = sev_uk_cpm;
		}
		else if (regionName == "Canada") {
			price = sev_ca_cpm;
		}
		else if (regionName == "North America") {
			price = sev_na_cpm;
		}
		else if (regionName == "Europe") {
			price = sev_eu_cpm;
		}
		else if (regionName == "Australia") {
			price = sev_au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = sev_untar_cpm;
		}
		else if (regionName == "English") {
			price = sev_en_cpm;
		}
	}
	else if (bannerType == "120x600") {
		if (regionName == "United States") {
			price = onetw_us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = onetw_uk_cpm;
		}
		else if (regionName == "Canada") {
			price = onetw_ca_cpm;
		}
		else if (regionName == "North America") {
			price = onetw_na_cpm;
		}
		else if (regionName == "Europe") {
			price = onetw_eu_cpm;
		}
		else if (regionName == "Australia") {
			price = onetw_au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = onetw_untar_cpm;
		}
		else if (regionName == "English") {
			price = onetw_en_cpm;
		}
	}
	else if (bannerType == "160x600") {
		if (regionName == "United States") {
			price = onesix_us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = onesix_uk_cpm;
		}
		else if (regionName == "Canada") {
			price = onesix_ca_cpm;
		}
		else if (regionName == "North America") {
			price = onesix_na_cpm;
		}
		else if (regionName == "Europe") {
			price = onesix_eu_cpm;
		}
		else if (regionName == "Australia") {
			price = onesix_au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = onesix_untar_cpm;
		}
		else if (regionName == "English") {
			price = onesix_en_cpm;
		}
	}
	else if (bannerType == "300x250") {
		if (regionName == "United States") {
			price = thr_us_cpm;
		}
		else if (regionName == "United Kingdom") {
			price = thr_uk_cpm;
		}
		else if (regionName == "Canada") {
			price = thr_ca_cpm;
		}
		else if (regionName == "North America") {
			price = thr_na_cpm;
		}
		else if (regionName == "Europe") {
			price = thr_eu_cpm;
		}
		else if (regionName == "Australia") {
			price = thr_au_cpm;
		}
		else if (regionName == "Worldwide") {
			price = thr_untar_cpm;
		}
		else if (regionName == "English") {
			price = thr_en_cpm;
		}
	}	
	return price;
}

function OSF_setPrice() {
	var pricefld, amountfld, adtypefld, regionfld, catfld;
	if (use_gebi) {
		pricefld = document.getElementById('OSF_xtotal');
		amountfld = document.getElementById('OSF_visitorno');
		adtypefld = document.getElementById('OSF_adtype');
		regionfld = document.getElementById('OSF_co');
		catfld = document.getElementById('OSF_cat');
	}
	else if (use_css) {
		pricefld = document.all['OSF_xtotal'];
		amountfld = document.all['OSF_visitorno'];
		adtypefld = document.all['OSF_adtype'];
		regionfld = document.all['OSF_co'];
		catfld = document.all['OSF_cat'];
	}
	else if (use_layers) {
		pricefld = document.layers['OSF_xtotal'];
		amountfld = document.layers['OSF_visitorno'];
		adtypefld = document.layers['OSF_adtype'];
		regionfld = document.layers['OSF_co'];
		catfld = document.layers['OSF_cat'];
	}

	var amount = amountfld.value;
	var region = regionfld.value;
	
	var cost = 0.00;
	if (adtypefld.value == "traffic") {
		var popsfld, soundfld;
		if (use_gebi) {
			popsfld = document.getElementById('OSF_pops1');
			soundfld = document.getElementById('OSF_sound1');
		}
		else if (use_css) {
			popsfld = document.all['OSF_pops1'];
			soundfld = document.all['OSF_sound1'];
		}
		else if (use_layers) {
			popsfld = document.layers['OSF_pops1'];
			soundfld = document.layers['OSF_sound1'];
		}

		var modpercent = 0.00;
		if (usePopsStaticPricing == 0) {
			if (popsfld.checked) {	
				modpercent = modpercent + popsPrice;
			}
		}
		if (useSoundStaticPricing == 0) {
			if (soundfld.checked) {
				modpercent = modpercent + soundPrice;
			}
		}
		if (useCatStaticPricing == 0) {
			if (catfld.value != catNAval) {
				modpercent = modpercent + catPrice;
			}
		}

		if (pricemode == 1) {
			var finalmod = 0.00;
			var split_threshold_amounts = vis_price_thresholds.split(":");
			for(var mythr = 0; mythr < split_threshold_amounts.length; mythr++){
				var fill_amount = split_threshold_amounts[mythr].split("|");
				var visitors = fill_amount[0];
				var pricemod = fill_amount[1];

				if (amount >= parseInt(visitors)) {
					finalmod = pricemod;
				}
			}
			
			modpercent = modpercent - parseFloat(finalmod);
		}

		var price = OSF_getPrice(region, "");
		price = price + (price * modpercent);

		if (usePopsStaticPricing == 1) {
			if (popsfld.checked) {	
				price = price + popsPrice;
			}
		}
		if (useSoundStaticPricing == 1) {
			if (soundfld.checked) {
				price = price + soundPrice;
			}
		}
		if (useCatStaticPricing == 1) {
			if (catfld.value != catNAval) {
				price = price + catPrice;
			}
		}
		cost = (amount/1000) * price;
	}
	else {
		var sizefld;
		if (use_gebi) {
			sizefld = document.getElementById('OSF_size');
		}
		else if (use_css) {
			sizefld = document.all['OSF_size'];
		}
		else if (use_layers) {
			sizefld = document.layers['OSF_size'];
		}
		var size = sizefld.value;
		var modpercent = 0.00;
		if (useCatStaticPricing == 0) {
			if (catfld.value != catNAval) {
				modpercent = modpercent + catPrice;
			}
		}

		if (pricemode == 1) {
			var finalmod = 0.00;
			var split_threshold_amounts = imp_price_thresholds.split(":");
			for(var mythr = 0; mythr < split_threshold_amounts.length; mythr++){
				var fill_amount = split_threshold_amounts[mythr].split("|");
				var visitors = fill_amount[0];
				var pricemod = fill_amount[1];

				if (amount >= parseInt(visitors)) {
					finalmod = pricemod;
				}
			}
			
			modpercent = modpercent - parseFloat(finalmod);
		}

		var price = OSF_getPrice(region, size);
		price = price + (price * modpercent);
		if (useCatStaticPricing == 1) {
			if (catfld.value != catNAval) {
				price = price + catPrice;
			}
		}
		cost = (amount/1000) * price;
	}
	
	if (Math.floor(cost * 100)/100 != cost) {
		cost = Math.ceil(cost*100)/100;
	}
	var tot2str = cost.toString();
	var tot2search = tot2str.indexOf(".");
	if (tot2search == -1) {
		cost = cost+".00";
	}else{
		var tot2split = tot2str.split(".");
		var tot2splitstr = tot2split[1].length;	
		if (tot2splitstr == 1) {
			cost = cost+"0";
		}		
	}

	pricefld.value = cost;
}

function OSF_purchase_tr() {
	var hasPopstd, adtypefld, xtotalfld, urlfld, visitornofld, cofld, catfld, itemnamefld, on0fld, os0fld;
	var amountfld, shopurlfld, cancelurlfld, businessfld, currencyfld, returnfld, addfld, notifyurlfld, ostrformelem;
	var imgurlfld, sizefld, on1fld, os1fld, popsfld, soundfld;
	if (use_gebi) {
		hasPopstd = document.getElementById('OSF_hasPops');
		adtypefld = document.getElementById('OSF_adtype');
		xtotalfld = document.getElementById('OSF_xtotal');
		urlfld = document.getElementById('OSF_xurl');
		visitornofld = document.getElementById('OSF_visitorno');
		cofld = document.getElementById('OSF_co');
		catfld = document.getElementById('OSF_cat');
		itemnamefld = document.getElementById('OSF_item_name');
		on0fld = document.getElementById('OSF_on0');
		os0fld = document.getElementById('OSF_os0');
		amountfld = document.getElementById('OSF_amount');
		shopurlfld = document.getElementById('OSF_shopping_url');
		cancelurlfld = document.getElementById('OSF_cancel_return');
		businessfld = document.getElementById('OSF_business');
		currencyfld = document.getElementById('OSF_currency_code');
		returnfld = document.getElementById('OSF_return');
		addfld = document.getElementById('OSF_add');
		notifyurlfld = document.getElementById('OSF_notify_url');
		ostrformelem = document.getElementById('OSF_ostrform');
		on1fld = document.getElementById('OSF_on1');
		os1fld = document.getElementById('OSF_os1');
		
		if (adtypefld.value == "banner") {
			imgurlfld = document.getElementById('OSF_imgurl');
			sizefld = document.getElementById('OSF_size');
		} else {
			popsfld = document.getElementById('OSF_pops1');
			soundfld = document.getElementById('OSF_sound1');
		}

	} else if (use_css) {
		hasPopstd = document.all['OSF_hasPops'];
		adtypefld = document.all['OSF_adtype'];
		xtotalfld = document.all['OSF_xtotal'];
		urlfld = document.all['OSF_xurl'];
		visitornofld = document.all['OSF_visitorno'];
		cofld = document.all['OSF_co'];
		catfld = document.all['OSF_cat'];
		itemnamefld = document.all['OSF_item_name'];
		on0fld = document.all['OSF_on0'];
		os0fld = document.all['OSF_os0'];
		amountfld = document.all['OSF_amount'];
		shopurlfld = document.all['OSF_shopping_url'];
		cancelurlfld = document.all['OSF_cancel_return'];
		businessfld = document.all['OSF_business'];
		currencyfld = document.all['OSF_currency_code'];
		returnfld = document.all['OSF_return'];
		addfld = document.all['OSF_add'];
		notifyurlfld = document.all['OSF_notify_url'];
		ostrformelem = document.all['OSF_ostrform'];
		on1fld = document.all['OSF_on1'];
		os1fld = document.all['OSF_os1'];
		if (adtypefld.value == "banner") {
			imgurlfld = document.all['OSF_imgurl'];
			sizefld = document.all['OSF_size'];
		} else {
			popsfld = document.all['OSF_pops1'];
			soundfld = document.all['OSF_sound1'];
		}
	} else if (use_layers) {
		hasPopstd = document.layers['OSF_hasPops'];
		adtypefld = document.layers['OSF_adtype'];
		xtotalfld = document.layers['OSF_xtotal'];
		urlfld = document.layers['OSF_xurl'];
		visitornofld = document.layers['OSF_visitorno'];
		cofld = document.layers['OSF_co'];
		catfld = document.layers['OSF_cat'];
		itemnamefld = document.layers['OSF_item_name'];
		on0fld = document.layers['OSF_on0'];
		os0fld = document.layers['OSF_os0'];
		amountfld = document.layers['OSF_amount'];
		shopurlfld = document.layers['OSF_shopping_url'];
		cancelurlfld = document.layers['OSF_cancel_return'];
		businessfld = document.layers['OSF_business'];
		currencyfld = document.layers['OSF_currency_code'];
		returnfld = document.layers['OSF_return'];
		addfld = document.layers['OSF_add'];
		notifyurlfld = document.layers['OSF_notify_url'];
		ostrformelem = document.layers['OSF_ostrform'];
		on1fld = document.layers['OSF_on1'];
		os1fld = document.layers['OSF_os1'];
		if (adtypefld.value == "banner") {
			imgurlfld = document.layers['OSF_imgurl'];
			sizefld = document.layers['OSF_size'];
		} else {
			popsfld = document.layers['OSF_pops1'];
			soundfld = document.layers['OSF_sound1'];
		}
	}
	var xtotal = xtotalfld.value;
	var urlstr = urlfld.value;

	if ((xtotal == "")) {
		if (adtypefld.value == "traffic") {
			visitornofld.value = min_visitor_amount;
		}
		else {
			visitornofld.value = min_impression_amount;
		}
		visitornofld.focus();
	}
	if ((xtotal > 0) && ((urlstr.length <= 9) || ((urlstr.indexOf("http://") == -1) && (urlstr.indexOf("https://") == -1)))) {
		urlfld.value = urlErrMsg;
		urlfld.focus();
	}

	var valid_region = 1;
	var region = cofld.value;
	if (region != "United States" && region != "United Kingdom" && region != "Canada" && region != "North America" && region != "Europe" && region != "Australia" && region != "Worldwide" && region != "English" && region != "Bulk") {
		valid_region = 0;
		cofld.focus();
	}

	if ((xtotal > 0) && (urlstr.length > 9) && (urlstr != urlErrMsg) && (valid_region == 1) && ((urlstr.indexOf("http://") != -1) || (urlstr.indexOf("https://") != -1))) {
		var dosubmit = 0;
		if (adtypefld.value == "traffic") {
			var traffic_type = cofld.value + "|" + catfld.value;
			itemnamefld.value = visitornofld.value + " Visitors: " + traffic_type;
			on0fld.value = "URL";
			os0fld.value = urlstr;

			on1fld.value = "Has Pops|Sound";
			var propvalue = "";
			if (popsfld.checked) {	
				propvalue = propvalue + "YES|";
			} else {
				propvalue = propvalue + "NO|";
			}
			if (soundfld.checked) {
				propvalue = propvalue + "YES";
			} else {
				propvalue = propvalue + "NO";
			}
			
			os1fld.value = propvalue;
			dosubmit = 1;
		}
		else {
			var imgurlstr = imgurlfld.value;
			if ((xtotal > 0) && ((imgurlstr.length <= 11) || ((imgurlstr.indexOf("http://") == -1) && (imgurlstr.indexOf("https://") == -1)))) {
				imgurlfld.value = urlErrMsg;
				imgurlfld.focus();
			}
			var imgext1 = OSF_get_img_format(imgurlstr);
			var imgext2 = OSF_get_img_format_four(imgurlstr);

			var verified_imgurl = 1;
			if ((imgext1 != "png") && (imgext1 != "jpg") && (imgext1 != "gif") && (imgext1 != "swf") && (imgext2 != "jpeg")) {
				imgurlfld.value = extErrMsg;
				verified_imgurl = 0;
				imgurlfld.focus();
			}
			
			var valid_size = 1;
			var sizeval = sizefld.value;
			if (sizeval != '468x60' && sizeval != '728x90' && sizeval != '120x600' && sizeval != '160x600' && sizeval != '300x250') {
				valid_size = 0;
				sizefld.focus();
			}

			if (region != "United States" && region != "United Kingdom" && region != "Canada" && region != "North America" && region != "Europe" && region != "Australia" && region != "Worldwide" && region != "English") {
				valid_region = 0;
				cofld.focus();
			}

			if ((xtotal > 0) && (imgurlstr.length > 11) && (verified_imgurl == 1) && (valid_size == 1) && (valid_region == 1) && (imgurlstr != urlErrMsg) && ((imgurlstr.indexOf("http://") != -1) || (imgurlstr.indexOf("https://") != -1))) {
				traffic_type = region + "-" + catfld.value;
				itemnamefld.value = visitornofld.value + " " + sizeval + " Impressions | " + traffic_type;
				on0fld.value = "Click_URL";
				os0fld.value = urlstr;
				on1fld.value = "Image_URL";
				os1fld.value = imgurlstr;
				dosubmit = 1;
			}
		}
		
		if (dosubmit == 1) {
			amountfld.value = xtotal;
			shopurlfld.value = order_pg_loc;
			cancelurlfld.value = order_pg_loc;
			businessfld.value = pp_email;
			currencyfld.value = ordering_cur;
			returnfld.value = return_page;
			addfld.value = "1";		
			if (allow_ipn == 1)  {
				notifyurlfld.value = ipn_path;
			}
			ostrformelem.submit();
		} else {
			if (hasPopstd.className == "OSF_ShowimgOptions" && adtypefld.value == "banner") {
				OSF_doAdType();
			}
		}
	}
	else {
		if (hasPopstd.className == "OSF_ShowimgOptions" && adtypefld.value == "banner") {
			OSF_doAdType();
		}
	}
}

function OSF_check_cart_tr() {
	var shopurlfld, cancelurlfld, businessfld, displayfld, ostrformelem, notifyurlfld;
	if (use_gebi) {
		shopurlfld = document.getElementById('OSF_shopping_url');
		cancelurlfld = document.getElementById('OSF_cancel_return');
		businessfld = document.getElementById('OSF_business');
		displayfld = document.getElementById('OSF_display');
		notifyurlfld = document.getElementById('OSF_notify_url');
		ostrformelem = document.getElementById('OSF_ostrform');
	} else if (use_css) {
		shopurlfld = document.all['OSF_shopping_url'];
		cancelurlfld = document.all['OSF_cancel_return'];
		businessfld = document.all['OSF_business'];
		displayfld = document.all['OSF_display'];
		notifyurlfld = document.all['OSF_notify_url'];
		ostrformelem = document.all['OSF_ostrform'];
	} else if (use_layers) {
		shopurlfld = document.layers['OSF_shopping_url'];
		cancelurlfld = document.layers['OSF_cancel_return'];
		businessfld = document.layers['OSF_business'];
		displayfld = document.layers['OSF_display'];
		notifyurlfld = document.layers['OSF_notify_url'];
		ostrformelem = document.layers['OSF_ostrform'];
	}
	shopurlfld.value = order_pg_loc;
	cancelurlfld.value = order_pg_loc;
	businessfld.value = pp_email;
	displayfld.value = "1";
	if (allow_ipn == 1)  {
		notifyurlfld.value = ipn_path;
	}
	ostrformelem.submit();
}

function OSF_get_img_format(ext) {
	var teststring12 = ext;
	var teststring122 = teststring12.toLowerCase();
	var teststring13 = teststring122.replace(/\//g, "");
	var teststring1 = teststring13.replace(/ /g, "");
	var total_length = teststring1.length;
	var startnum = total_length - 3;
	var finalstr = teststring1.substr(startnum,3);
	return finalstr;
}

function OSF_get_img_format_four(ext) {
	var teststring12 = ext;
	var teststring122 = teststring12.toLowerCase();
	var teststring13 = teststring122.replace(/\//g, "");
	var teststring1 = teststring13.replace(/ /g, "");
	var total_length = teststring1.length;
	var startnum = total_length - 4;
	var finalstr = teststring1.substr(startnum,4);
	return finalstr;
}

function getAnchorPositionXY(anchorname) {
 	var useWindow=false;
 	var coordinates=new Object();
 	var x=0,y=0;
 	//var use_gebi=false, use_css=false, use_layers=false;
 	//if (document.getElementById) { use_gebi=true; }
 	//else if (document.all) { use_css=true; }
 	//else if (document.layers) { use_layers=true; } 	
  	if (use_gebi && document.all) {
 		x=AnchorPosition_getPageOffsetLeftXY(document.all[anchorname]);
 		y=AnchorPosition_getPageOffsetTopXY(document.all[anchorname]);
 		}
 	else if (use_gebi) {
 		var o=document.getElementById(anchorname);
 		x=AnchorPosition_getPageOffsetLeftXY(o);
 		y=AnchorPosition_getPageOffsetTopXY(o);
 		}
  	else if (use_css) {
 		x=AnchorPosition_getPageOffsetLeftXY(document.all[anchorname]);
 		y=AnchorPosition_getPageOffsetTopXY(document.all[anchorname]);
 		}
 	else if (use_layers) {
 		var found=0;
 		for (var i=0; i<document.anchors.length; i++) {
 			if (document.anchors[i].name==anchorname) { found=1; break; }
 			}
 		if (found==0) {
 			coordinates.x=0; coordinates.y=0; return coordinates;
 			}
 		x=document.anchors[i].x;
 		y=document.anchors[i].y;
 		}
 	else {
 		coordinates.x=0; coordinates.y=0; return coordinates;
 		}
 	coordinates.x=x;
 	coordinates.y=y;
 	return coordinates;

 }

 function AnchorPosition_getPageOffsetLeftXY (el) {
 	var ol=el.offsetLeft;
 	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
 	return ol;
 }

 function AnchorPosition_getPageOffsetTopXY (el) {
 	var ot=el.offsetTop;
 	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
 	return ot;
}

function OSF_close_out_div_pt () {
	if (!use_css && use_gebi){
		document.getElementById('OSF_imgTestDiv').style.top = -695+"px";
	} 
	if (use_layers) {
		document.layers["OSF_imgTestDiv"].style.top = -695;
	}
	if (use_css) {
		document.all["OSF_imgTestDiv"].style.top = -695;
	}
}