//Set WIN IE Variable for fixPNG Function
var ie55up = true

<!-- PNG Transparency Function - WIN IE 5.5 or Higher -->
function fixPNG(myImage) {

	if (window.ie55up) {
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle

		strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";"
		strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"

		myImage.outerHTML = strNewHTML
	}

}//End PNG Transparency Function


<!-- Expand / Collapse -->
function expandCollapse(divID, imgID) {

	element = document.getElementById(divID);
	image = document.getElementById(imgID);

	if(element.style.display=='none'){
		element.style.display="block";

		image.src = "images/minus.jpg";

	}else{
		element.style.display ="none";

		image.src = "images/plus.jpg";

	}

}//End Expand & Collapse Function

<!-- Expand/Collapse Table -->
function expandTable(divID, imgID) {
	element = document.getElementById(divID);
	image = document.getElementById(imgID);

	var browserName=navigator.appName; 
	
	if (browserName=="Microsoft Internet Explorer")
	{
		if (element.style.display=='none')
		{	
			element.style.display="block";
			image.src = "images/minus.jpg";
		}
		else
		{
			element.style.display="none";
			image.src = "images/plus.jpg";
		}
	}
	else 
	{
		if (element.style.display=='none')
		{	
			element.style.display="table";
			image.src = "images/minus.jpg";
		} else
		{
			element.style.display="none";
			image.src = "images/plus.jpg";
		}
	}
}//End Expand/Collape Table


<!-- Expand / Collapse Tasks -->
function taskExpand(divID) {

	element = document.getElementById(divID);

	if(element.style.display=='none'){
		element.style.display="block";

	}else{
		element.style.display ="none";

	}

}//End Expand & Collapse Function

<!-- Expand / Collapse Tasks -->
function taskExpandRow(divID) {

	element = document.getElementById(divID);

	if(element.style.display=='none'){
		element.style.display="";

	}else{
		element.style.display ="none";

	}

}//End Expand & Collapse Function


<!-- Begin Print Page -->
function printPage() {
	window.print();
}
<!-- End Print Page -->

function getStrippedHref(href) {

	return href.protocol+'//'+href.host+href.pathname;

}

function reloadParentHref(href, query) {

	newLocation = getStrippedHref(href);
	newLocation = newLocation + query;

	//alert(newLocation);
	window.opener.location.href = newLocation;

}


<!-- Start Notes Popup Window -->
function openNotes(id, oId){
	window.open("notes.php?id="+id+"&orderId="+oId, "Notes", "height=550,width=925,toolbar=no,scrollbars=yes");
}//End Notes Popup Window

<!-- Start Notes Popup Window -->
function openTeamDetails(id, domain){
	window.open("custTeamDetails.php?id="+id+"&domain="+domain, "Team_Details", "height=550,width=925,toolbar=no,scrollbars=yes");
}//End Notes Popup Window

<!-- Start Invoices Popup Window - PRINT -->
function openInvoice(rep, dateComplete, team, worktype){
	window.open("invoiceReportPrint.php?rep="+rep+"&dateComplete="+dateComplete+"&team="+team+"&worktype="+worktype, "Invoice", "height=800,width=925,toolbar=no,scrollbars=yes");
}//End Invoices Popup Window

<!-- Start Payment Details Popup Window -->
function openPaymentDetails(oId){
	window.open("paymentDetails.php?orderId="+oId, "Payments", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Payment Details Popup Window


<!-- Start Order Cancel Popup Window -->
function openCancel(oId, cId){
	window.open("cancelOrder.php?orderId="+oId+"&customerId="+cId, "Cancel", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window

<!-- Start Order Cancel Popup Window -->
function openCancelSub(subId, cId){
	window.open("cancelSubscription.php?subscriptionId="+subId+"&customerId="+cId, "Cancel", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window

<!-- Start Order Cancel Popup Window -->
function openDeleteOrder(oId, cId){
	window.open("deleteOrder.php?orderId="+oId+"&customerId="+cId, "Cancel", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window

<!-- Start Order Lock Popup Window -->
function openLockOrder(oId, cId){
	window.open("lockOrder.php?orderId="+oId+"&customerId="+cId, "Cancel", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Lock Popup Window

<!-- Start Order Unlock Popup Window -->
function openUnlockOrder(oId, cId){
	window.open("unlockOrder.php?orderId="+oId+"&customerId="+cId, "Cancel", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Unlock Popup Window

<!-- Start Order Lock Popup Window -->
function openEnableCalendar(cId){
	window.open("enableCalendar.php?customerId="+cId, "Cancel", "height=20,width=400,toolbar=no,scrollbars=yes");
}//End Order Lock Popup Window

<!-- Start Order Cancel Popup Window -->
function openDelete(cId, oId, type, id){
	window.open("deleteItem.php?orderId="+oId+"&customerId="+cId+"&item_type="+type+"&item_id="+id, "Delete", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window


<!-- Start Order Reactivate Popup Window -->
function openReactivate(oId, cId){
	window.open("reactivateOrder.php?orderId="+oId+"&customerId="+cId, "Reactivate", "height=400,width=925,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window

<!-- Start Order Switcher Popup Window -->
function openSwitcher(oId, cId){
	window.open("orderSwitcher.php?orderId="+oId+"&customerId="+cId, "Switcher", "height=400,width=980,toolbar=no,scrollbars=yes");
}//End Order Cancel Popup Window

<!-- Start Team List Popup Window - PRINT -->
function openTeamList(){
	window.open("teamListPrint.php", "Teams", "height=800,width=925,toolbar=no,scrollbars=yes");
}//End Team List Popup Window


<!-- Start Affiliate Report Popup Window - PRINT -->
function openAffiliate(){
	window.open("affiliateReportPrint.php", "Affiliate", "height=800,width=750,toolbar=no,scrollbars=yes");
}//End Affiliate Report Popup Window

<!-- Start Affiliate Report Popup Window - PRINT -->
function openPaymentIssueFixer(queue_id){
	window.open("paymentIssueFixer.php?queue_id="+queue_id, "Fix_Payment_Issue", "height=400,width=1020,toolbar=no,scrollbars=yes");
}//End Affiliate Report Popup Window

<!-- Start Team Wizard Popup Window -->
function openWizard(url){
	window.open(url, "Wizard", "height=550,width=925,toolbar=no,scrollbars=yes");
}//End Notes Popup Window

<!-- Start Team Wizard Popup Window -->
function openInfo(url, id){

	if(id > 0) window.open(url+"?id="+id, "Wizard", "height=550,width=925,toolbar=no,scrollbars=yes");

}//End Notes Popup Window

<!-- Start Generate Config Popup Window -->
function openConfig(domain, id, team_id){

        window.open("generateConfig.php?domain="+domain+"&domain_id="+id+"&team_id="+team_id, "Generate_Config", "height=450,width=900, toolbar=no,scrollbars=yes");

}//End Notes Popup Window


<!-- Validation on Work Orders - workOrders.php -->
function validateWorkOrders() {

	//Validate Representative
	if(document.form.repId.selectedIndex==0) {
         alert('Please Select a Representative');
         document.form.repId.focus();
         return false;
    }
	//Validate Work Type
	if(document.form.worktype.selectedIndex==0) {
         alert('Please Select a Work Type');
         document.form.worktype.focus();
         return false;
    }
	//Validate Team
//	if(document.form.domainId.selectedIndex==0){
//   		alert("Please Select a Team");
//		document.form.domainId.focus();
//		return false;
//	}

	//Validate Rate
	if(document.form.rate.selectedIndex==0){
   		alert("Please Select a Rate");
		document.form.rate.focus();
		return false;
	}
	//Validate Hours
	if(document.form.hours.selectedIndex==0){
   		alert("Please Select Hours");
		document.form.hours.focus();
		return false;
	}
	//Validate Subject
	if(document.form.subject.value == ""){
   		alert("Please Enter a Subject");
		form.subject.focus();
		return false;
	}
	//Validate Description
    if(document.form.notes.value == "") {
         alert('Please Enter a Description');
         document.form.notes.focus();
         return false;
    }

}//End Work Order Validation


<!-- Validation on Support Queue - supportQueue.php -->
function validateSupportQueue(form) {

	//Validate Answer
    	if(form.result.value == "") {
        	alert('Please Answer the Support Issue');
         	form.result.focus();
         	return false;
    	}

}//End Support Queue Validation


<!-- Validation on Support Queue - supportQueue.php -->
function validateMerge(form) {

	//Validate Answer

	found = 0;

	if(form.merge_customer.length){
		for(var i=0; i < form.merge_customer.length; i++){

			//alert(form.merge_customer[i].checked);
			if(form.merge_customer[i].checked == true) found=1;

		}
	}else{

		if(form.merge_customer.checked) found=1;

	}

	if(found == 0) {
		alert('Select a Customer to Merge');
		return false;
	}

}//End Support Queue Validation

<!-- Validation on Support Queue - supportQueue.php -->
function validateTeamDetails(teamDetails) {

	//Validate Team Details
	if(document.teamDetails.domain.selectedIndex==0){
   		alert("Please Select a Team to View");
		document.teamDetails.domain.focus();
		return false;
	}

}//End Support Queue Validation


<!-- Validation on Support Queue - supportQueue.php -->
function validatePaymentIssue() {

	//Validate Answer
   	myOption = -1;

	if(document.orders.order_id.length){
		for (i=0; i < document.orders.order_id.length; i++) {

			if (document.orders.order_id[i].checked) {
				myOption = i;

			}
		}
	}else{

		if (document.orders.order_id.checked) {
			myOption = i;

		}
	}
   	if (myOption == -1) {
         alert('Please Select An Order');
		return false;

    }

	return true;
}//End Support Queue Validation


function addPackage(fromID, toID){

	fromElement = document.getElementById(fromID);
	toElement = document.getElementById(toID);

	fromText = fromElement.options[fromElement.options.selectedIndex].text;
	fromVal = fromElement.options[fromElement.options.selectedIndex].value;

	index = toElement.length;

	var has  = false;

	for(i=0; i < index; i++){

		if(toElement.options[i].value == fromVal) has = true;

	}

	if(!has){

		toElement.options[index] = new Option(fromText, fromVal);

	}

}

function removePackage(fromID){

	fromElement = document.getElementById(fromID);

	fromElement.remove(fromElement.options.selectedIndex);

}

function selectPackages(toID){

	toElement = document.getElementById(toID);

	var index = toElement.length;

	for(i=0; i < index; i++){

		toElement.options[i].selected = true;

	}

}

function addItemToParent(parentDropdown, itemName, itemVal){

	dropDown = parentDropdown;

	if(dropDown){


		var optionName = window.opener.document.createElement("OPTION");
		dropDown.options.add(optionName);
		var selectLength = dropDown.length;
		dropDown.options[selectLength-1].value = itemVal;
		dropDown.options[selectLength-1].innerText = itemName;

		dropDown.options[dropDown.length - 1].selected = true;
	}

}

function validate_beanstream(form) {


	if (form.first_name.value == ""){
		alert("Please enter your first name.");
		form.first_name.focus();
		return false;
	}

	if (form.last_name.value == ""){
		alert("Please enter your last name.");
		form.last_name.focus();
		return false;
	}

	if (form.email.value == ""){
		alert("Please enter your email address.");
		form.email.focus();
		return false;
	}
	
	if (form.address.value == ""){
		alert("Please enter your address.");
		form.address.focus();
		return false;
	}

	if (form.city.value == ""){
		alert("Please enter your city.");
		form.shipCity.focus();
		return false;
	}

	if (form.zip.value == ""){
		alert("Please enter your zip/postal code.");
		form.zip.focus();
		return false;
	}

	if (form.country.selectedIndex == 0){
		alert("Please select a country.");
		form.country.focus();
		return false;
	}

	if ((form.country.options[form.country.selectedIndex].value == 'CA' || form.country.options[form.country.selectedIndex].value == 'US') && form.state.selectedIndex == 0){
		alert("Please select a state/province.");
		form.state.focus();
		return false;
	}

	if (form.card_owner.value == ""){
		alert("Please enter the name on the card");
		form.card_owner.focus();
		return false;
	}

	if (form.card_number.value == "" || form.card_number.value.length < 15){
		alert("Please enter a valid card number.");
		form.card_number.focus();
		return false;
	}

	if (form.card_exp_month.selectedIndex == 0){
		alert("Please select a card expiry month.");
		form.card_exp_month.focus();
		return false;
	}

	if (form.card_exp_year.selectedIndex == 0){
		alert("Please select a card expiry year.");
		form.card_exp_year.focus();
		return false;
	}

	return true;

}

/*************************************
Sets the work order dropdowns to
worktype=non-billable
teamname=platinumsynergy.com
rate=80/hr
Added 11.23.06

Updated Tuesday Feb 13th. 
	Work order page was changed to an auto complete
	text box for the domain name. 

Updated June 6th, 2007
	Work order changed to be able to pass internal 
	or external type also sets rate for user
	1 = internal
	2 = external
**************************************/
function SetDropdowns(type, rate)
{
	var teamList = document.getElementById("domainname");
	var teamIndex = 0;

	//Set form values based on type being passed
	if (type == 1)
	{
		document.getElementById("worktype").selectedIndex = 2;
		document.getElementById("rate").selectedIndex = rate;
		document.form.domain_string.value = 'platinumsynergy.com';
		document.getElementById("setdropdown").onclick = function(){SetDropdowns(2,rate)};
		document.getElementById("setdropdown").value = 'External';
	}
	if (type == 2)
	{
		document.getElementById("worktype").selectedIndex = 1;
		document.getElementById("rate").selectedIndex = rate;
		document.form.domain_string.value = '';
		document.getElementById("setdropdown").onclick = function(){SetDropdowns(1,rate)};
		document.getElementById("setdropdown").value = 'Internal';
	}
	
	//Find the index of platinumsynergy.com
	/*for(i = 0; i<teamList.length;i++)
	{
		if(teamList.options[i].text == "platinumsynergy.com")
		{
			teamIndex = i;
			break;
		}
	}
	teamList.selectedIndex = teamIndex;
	*/

}

function setSelected(repId) 
{
	var sel = document.getElementById("repId");
	var selId = -1;
	for (i=0; i < sel.options.length && selId == -1; i++) 
	{
		if (sel.options[i].value == repId) 
		{
			selId = i;
		}
	}
	sel.selectedIndex = selId;
}