﻿var msg = "Thank you for contacting Premier Sports Motion Video\nWe will review your email request and contact you shortly.\nThank You.";
function loader()
{
	var id = document.getElementById('pageName');
	hiliteNav(id);
}
function setFocus(id)
{
    try
    {
        document.getElementById(id).focus();
    }
    catch(ex)
    {}
}

function LoadClientVideo()
{
	var uid = document.getElementById("txtUserID");
	var pwd = document.getElementById("txtPwd");
	var lblError = document.getElementById("lblLoginError");
	var url = "";
	var errmsg = "";

	if(uid.value.length < 1)
	{
		errmsg += "Login Error:<br/>UserID is required.";
	}
	if(pwd.value.length < 1)
	{
		errmsg += "Login Error:<br/>Password is required.";
	}
	if(errmsg != "")
	{
		lblError.innerHTML = errmsg;
	}
	else
	{	
		try
		{
			url = "admin/videos/clientvideo.aspx?uid="+uid.value+"&pwd="+pwd.value;
			newWindow(url);
			lblError.innerHTML = "";
		
		}
		catch(er)
		{
			lblError.innerHTML = "Login Error:<br/>" + er.message;
		}
	}
	
}
function ResetErrors()
{
	var lblError = document.getElementById("lblLoginError");
	try
	{
		lblError.innerHTML = "";
	}
	catch(er)
	{
	}


}
function PrevPageNav()
{
   var p = "";
   try
   {
        p = document.getElementById("pageName");
        if (p.value == "menu")
        {
            document.getElementById("PrevPageNav").style.display="block";
        }
        else
        {
            document.getElementById("PrevPageNav").style.display="none";
        }
   }
   catch(ex)
   {
        document.getElementById("PrevPageNav").style.display="none";
   } 
}
function LinkTargets()
{
    var id = "";
    try{
    id = document.getElementById("linkTargets");
    
    var a = id.getElementsByTagName("a");
        for(i=0; i<a.length; i++)
        {
          a[i].setAttribute("target", "_blank")
        }
    }
    catch(ex)
    {
        // dont do anything
    }
}
function SetImage(fileName)
{
    try
    {
        document.getElementById('defaultImage1_hidDefault').value = fileName;
        document.getElementById('defaultImage1_imgDefault').src = "pix/"+ fileName;
    }
    catch(errMsg)
    {
       //do nothing
    }
}
function Alert(msg)
{
    alert(msg);
}
function newWindow(url)
{
    window.open(url,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=740, height=500");
}
function shipconfirm()
{
	if (confirm("Confirm Ship!")==true) 
		{
		return true; 
		}
	else 
	{
		alert('Action cancelled.');
		return false; 
	}
}

function getconfirm() 
{
	if (confirm("Confirm Delete!")==true) 
		{
		return true; 
		}
	else 
	{
		alert('Deletion(s) have been cancelled.');
		return false; 
	}
}
function select_deselectAll (chkVal, idVal) 
{ 
	var frm = document.forms[0];
	// Loop through all elements
	for (i=0; i<frm.length; i++) 
	{
		// Look for our Header Template's Checkbox
		if (idVal.indexOf ('CheckAll') != -1) 
		{
			// Check if main checkbox is checked, then select or deselect datagrid checkboxes 
			if(chkVal == true) 
			{
				frm.elements[i].checked = true;
			} 
			else 
			{
				frm.elements[i].checked = false;
			}
			// Work here with the Item Template's multiple checkboxes
		} 
		else if (idVal.indexOf ('DeleteThis') != -1) 
		{
			// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
			if(frm.elements[i].checked == false) 
			{
				frm.elements[1].checked = false; //Uncheck main select all checkbox
			}
		}
	}
}
function swapImgOn()
{
	document.getElementById('bulletImg').src = "images/BulletNavs5.jpg";
}
function swapImgOff()
{
	document.getElementById('bulletImg').src = "images/BulletNavs6.jpg";
}

function hiliteNav(pageName)
{
	var lnk = ""; //.toLowerCase();
	try
	{
		lnk = "link"+pageName.value;
		document.getElementById(lnk).className = "activeTab";

	}
	catch(err)
	{
		//alert(err.Message);
	}
}
function hiliteMenu(el)
{
	var id = el.id;
	//document.getElementById(id).style.backgroundColor = 'transparent';
	document.getElementById(id).className = 'ProductsHover';
	//document.getElementById(id).style.backgroundImage = "url('../images/prod_Bkgd.gif')";

	
}
function deHiliteMenu(el)
{
	var id = el.id;
	//document.getElementById(id).style.backgroundColor = '#fff';
	document.getElementById(id).className = 'Products';
	//document.getElementById(id).style.backgroundImage = "";

}

function showMenu(id)
{
	var x = document.getElementById(id);
	if(x.style.display == "none")
	{
		x.style.display = "block";
	}
	else
	{
		x.style.display = "none";
	}
}
function hideMenu(id)
{
	document.getElementById(id).style.display = "none";
}

var arr = "";
function validateForm(ids)
{
	arr = ids.split(",");
	var isGood = false;
	for (i=0;i<=arr.length;i++)
	{
		var id = document.getElementById(arr[i]);
		if (id.value.length < 1)
		{
		
			if(id.id == "Email")
			{
				if(id.value.indexOf("@") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
				else if(id.value.indexOf(".") < 1)
				{
					alert("Valid email is required!");
					isGood = false;
					break;
				}
			}
			else
			{
				alert(id.id + " is required!");
				isGood = false;
				break;
			}
		}
		else
		{
			isGood = true;
		}
	}
	if (isGood)
	{
		sendEmail(ids);
	}
	return isGood;
}
function sendEmail()
{
		// strip array of any bad values
		for (i=0;i<=arr.length;i++)
		{
			var id = document.getElementById(arr[i]);
			try
			{
				id.value.Replace("<", "");
				id.value.Replace("/>", "");
				id.value.Replace("[", "");
				id.value.Replace("]", "");
				id.value.Replace("'", "");
				id.value.Replace("\"", "");
				id.value.toLowerCase().Replace("select", "");
			}
			catch(err)
			{}
		}

	var form = document.getElementById('ContactUs');

	//ajax email
}
var OptionVal1 = "";
var OptionName1 = "";
var amount = "";
function ItemOpt(val)
{
    var arr = val.split(", ");
    OptionVal1 = arr[1];
    amount = arr[0];
    OptionName1 = "Item";//arr[1];

}
function AddToCart(item_name, item_number, shipping, strOpt)
{
   
    var optName = "";
    
    if (strOpt == "")
    {
        optValue = "";
        optName = "";
    }
    else
    {
        optValue = strOpt;
        optName = "Option";
    }
    var atcForm = document.getElementById("AddToCart");
    document.getElementById("item_name").value = item_name;
    document.getElementById("item_number").value = item_number + ": " + item_name;
    document.getElementById("amount").value = amount;
    document.getElementById("on0").value = OptionName1;
	document.getElementById("os0").value = OptionVal1;
    document.getElementById("on1").value = optName;
	document.getElementById("os1").value = optValue;
	//document.getElementById("no_shipping").value = shipping;	
	//document.getElementById("shipping").value = shipping;	
	atcForm.action = "https://www.paypal.com/cgi-bin/webscr"
	atcForm.method = "Post"
	atcForm.target = "paypal"
	atcForm.submit()
	
	strOpt = "";
	optValue = "";
	optName = "";
}
// adds new pricing and pricing description
var rowCnt = 0;
function AddNewItemPriceRow(divID)
{
    var el = document.getElementById(divID);
    el.style.display="block";
    //rowCnt += 1;    
    //var row = "<div><span>Price:</span><input type=\"text\" id=\"price"+rowCnt +"\"  /> Add Option Description:<input type=\"text\" id=\"priceDesc"+rowCnt +"\" style=\"width:200px;\" /> <a href=\"javascript:AddNewItemPriceRow('AddItemPrice');\">+ Add</a></div>";
    //el.innerHTML += row;
}
function RemoveNewItemPriceRow(id)
{
    var el = document.getElementById("p"+id);
    document.getElementById("price"+id).value = "";
    document.getElementById("priceDesc"+id).value = "";
    el.style.display="none";
}
//
function drawFlash(theFile,w,h)
{
	var file = theFile;
	var str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='"+w+"' height='"+h+"' id='Flash Animation' align='middle'>"
	str += "<param name='allowScriptAccess' value='sameDomain' />"
	str += "<param name='movie' value='" + file + "' />"
	str += "<param name='quality' value='high' />"
	str += "<param name='wmode' value='transparent' />"
	str += "<embed src='" + file + "' quality='high' wmode='transparent' width='"+w+"' height='"+h+"' name='Flash Animation' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	str += "<" + "/" + "" + "object>"
	document.write(str);
}

var xmlHttp;
var myDiv;
var myPage;
function getData(elemID, page, query) {

	myDiv = elemID; //the div to display data
	myPage = page; //the serverpage to get the data from
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url=page;
	url=url+"?q="+query;
	url=url+"&sid="+Math.random();

	//alert(url);
	
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged() 
{
    try {
        if (xmlHttp.readyState == 4) {
            document.getElementById(myDiv).innerHTML = xmlHttp.responseText;
        }
        else {
            document.getElementById(myDiv).innerHTML = "<h3>Loading...</h3>";
        }
    }
    catch (e) {
        //alert(e.message);
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
catch (e)
	{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
}
return xmlHttp;
}










