function popupSized(url,width,height){
window.open(url,'_blank','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,screenX=310,screenY=60,left=310,top=60,width=' + width + ',height=' + height);
}


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		navProducts_over = newImage("/media/nav/navProducts-over.gif");
		navServices_over = newImage("/media/nav/navServices-over.gif");
		navNetwork_over = newImage("/media/nav/navNetwork-over.gif");
		navCorporate_over = newImage("/media/nav/navCorporate-over.gif");
		navPress_over = newImage("/media/nav/navPress-over.gif");
		navSite_over = newImage("/media/nav/navSite-over.gif");
		navContact_over = newImage("/media/nav/navContact-over.gif");
		navAffil_over = newImage("/media/nav/navAffil-over.gif");
		preloadFlag = true;
	}
}

preloadImages();

var theImages = new Array()

theImages[0] = '/media/rotate/pi-arts.gif'
theImages[1] = '/media/rotate/pi-news.gif'
theImages[2] = '/media/rotate/pi-events.gif'
theImages[3] = '/media/rotate/pi-over.gif'
theImages[4] = '/media/rotate/logo.gif'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" WIDTH="396" HEIGHT="260" BORDER="0" >');
}

function load(url,target,options) {
  if (target != '') {
    target.window.location.href = url;
    target.window.focus();
    if (options.indexOf('close') != -1) {
      top.close();
    }
  }
  else {
    window.location.href = url;
    window.focus();
  }
}


function loadinparent(url, closeSelf){
self.opener.location = url;
if(closeSelf) self.close();
}


var yourstation="demo";


function redirect(){
			parent.location.href="http://www2.publicinteractive.com/contact/"
		}







function validator(audiencevform) {
	// is aqh empty?
	if(audiencevform.aqh.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the AQH field");
		return false;
	}

// is certify empty?
	if(audiencevform.certify.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Agree and Certify field");
		return false;
	}

	// is first empty?
	if(audiencevform.first.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the First Name field");
		return false;
	}

	// is last empty?
	if(audiencevform.last.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Last Name field");
		return false;
	}

	// is organization empty?
	if(audiencevform.organization.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Organization field");
		return false;
	}

	// is emailaddress empty?
	if(audiencevform.emailaddress.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Email Address field");
		return false;
	}

	// is date empty?
	if(audiencevform.date.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Date field");
		return false;
	}

	return true;
}
          

function publicwordvalidator(publicword) {

	// is first empty?
	if(publicword.first.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the First Name field");
		return false;
	}

	// is last empty?
	if(publicword.last.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Last Name field");
		return false;
	}

	// is organization empty?
	if(publicword.organization.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Organization field");
		return false;
	}

	// is email empty?
	if(publicword.email.value == "") {
		// it is empty, so alert them and don't submit the form
		alert("You must enter a value for the Email Address field");
		return false;
	}

	return true;
}
          

function pickTip() {
	var a = Math.floor(Math.random()*18) + 1;
	var b = "howto_" + a;
	document.getElementById(b).style.display = '';
}

function elabsHrefConverter() {
	hrefstring = unescape(location.search.substring(1)); 
	var hrefarray = hrefstring.split('&'); 
	for (variable in hrefarray) { 
		varstring = hrefarray[variable]; 
		varname = varstring.substring(0,varstring.search('='));
		if (varname == "sender") { 
			email = varstring.split('=')[1]; 
			if (email.search(/[^@]+@[^.]+(.[^.]+)+/) > -1) { 
				document.getElementsByName('sender')[0].value = email;
			} 
		} 
		endvalue = varstring.split('=')[1]; 
		elementobject = document.getElementsByName(varname)[0]; 
		if (elementobject) { 
			document.getElementsByName(varname)[0].value = endvalue; 
			alert(endvalue);
		} 
	}
}


// check email in text box
function checkEmail(action) {
	var emailDefault = "you@email.com";
	var email = document.emailSubForm.user_email.value;
	if (action == "focus") {
		if (email == emailDefault) {
			document.emailSubForm.user_email.value = "";
		}
	} else if (action == "blur") {
		if (email == "") {
			document.emailSubForm.user_email.value = emailDefault;
		}
	}	
}

function elabsHrefConverter() { 
hrefstring = unescape(location.search.substring(1));
var hrefarray = hrefstring.split('&');
for (variable in hrefarray) {
		varstring = hrefarray[variable];
		varname = varstring.substring(0,varstring.search('='));
		if (varname == "sender") {
			email = varstring.split('=')[1];
			if (email.search(/[^@]+@[^.]+(.[^.]+)+/) > -1) {
				document.getElementsByName('sender')[0].value = email;
			}
		}
		endvalue = varstring.split('=')[1];
		elementobject = document.getElementsByName(varname)[0];
		if (elementobject) {
			document.getElementsByName(varname)[0].value = endvalue;
		}
	}
}


//Applies only to IE 4+
//0=no, 1=yes
var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}

// Validation for Sound Exchange Registraion Form - hdanila 06/2009

function sxRegFormCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("stationName", "stationCallLetters", "primaryContact", "primaryContactEmail", "primaryContactPhone", "secondaryContact", "secondaryContactEmail", "secondaryContactPhone", "address1", "city", "state", "zip", "playlistGenerationApp", "stream1", "stream1Format", "stream1Host", "stationAffiliation");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Station Name", "Station Call Letters", "Primary Contact", "Primary Contact Email", "Primary Contact Phone", "Secondary Contact", "Secondary Contact Email", "Secondary Contact Phone", "Address", "City", "State", "Zip/Postal Code", "Playlist Generation Application", "Stream 1", "Stream 1 Format", "Stream 1 Host/CDN", "Station Affiliation(s)");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}



// Validation for Mobile Schedule Form - hdanila 06/2009

function mobileScheduleFormCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("name", "email", "station", "stream");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Full Name", "Email", "Station Call Letters",  "Stream Name");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}



// Validation for Streaming Specs Form - hdanila 10/2009

function streamSpecsFormCheck(formobj){
	
	if (!validateDropdown (formobj)) return false;
	
	// Enter name of mandatory fields
	var fieldRequired = Array("stationname", "streamformat", "bitrate", "primarycontact", "email", "phone", "gatewayadd", "dnsinfo", "firewall");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Station call letters/Name of Stream", "Stream Format", "Streaming bit rate", "Primary Contact", "E-mail", "Primary Phone", "Gateway Address", "DNS Info", "Firewall");
	// dialog message
	var alertMsg = "Please complete the following field:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function validateDropdown(objForm)
{

	if (objForm.recipient.selectedIndex == 0) {
		alert("Please select Streaming Package.");
		return false;
	};
	
	return true;
}