// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring, strVersion;
var strCode;
var strSUP, strUL, strLI

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (checkIt('fire')) browser = "Fire Fox"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('win')) OS = "Windows";
	else if (checkIt('312.5')) OS = "OldMac";
	else if (checkIt('mac')) OS = "Mac";
	else OS = "an unknown operating system";
}



function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

  


function isDefined(property) {
  return (typeof property != 'undefined');
}





function formCheck(strRequest, strReturn, strForm, strError)
{
	var intCount = document.forms[strForm].length;
	var i = 0;
	var bSendFlag = true;
	
	while(i != intCount)
	{
		if(document.forms[strForm].elements[i].value == "")
		{
				var strName = document.forms[strForm].elements[i].name;
				
				if(strName.indexOf("*") != -1)
				{
					var iLength = strName.length;
					strName = strName.substring(1, iLength);
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					strName = strName.replace("_", " ");
					
					var obj = window.parent.document.getElementById(strError);
	
						obj.innerHTML = '<span class="error">Please fill in the ' + strName + ' field.</span>';
						
						document.forms[strForm].elements[document.forms[strForm].elements[i].name].focus();
						bSendFlag = false;
						break;
				}
				i = i+1;
		}
		else
		{
			i = i+1;
		}
		
	}

	if(bSendFlag == true)
	{		
		document.forms[strForm].submit();
	}
}



function formCheck2(strRequest, strReturnPage, strErrorReturnPage, strForm, strError)
{
	var intCount = document.forms[strForm].length;
	var i = 0;
	var bSendFlag = true;
	
	while(i != intCount)
	{
		if(document.forms[strForm].elements[i].value == "")
		{
				var strName = document.forms[strForm].elements[i].name;
				
				if(strName.indexOf("*") != -1)
				{
					var iLength = strName.length;
					strName = strName.substring(1, iLength);
					strName = strName.replace("_", " ");
					
					var obj = document.getElementById(strError);
	
						obj.innerHTML = '<span class="error">*Please fill in the <B>' + strName + '</B> field.</span>';
						
						document.forms[strForm].elements[document.forms[strForm].elements[i].name].focus();
						bSendFlag = false;
						break;
				}
				i = i+1;
		}
		else
		{
			i = i+1;
		}
		
	}


	
	if(bSendFlag == true)
	{
		
			//bSendFlag = CheckEmail();
			//bSendFlag = CheckDate();
			
			
			
			//if(bSendFlag == true)
			//{
				document.forms[strForm].method = "post";
				document.forms[strForm].submit();
			//}
			
	}
}


function CheckDate()
{
	var strDate = document.data1.elements["*Delivery_Date"].value;
	var bFlag = true;
	
	if(isNumber(strDate.charAt(0)) == false ||  isNumber(strDate.charAt(1)) == false || isNumber(strDate.charAt(3)) == false || isNumber(strDate.charAt(4)) == false || isNumber(strDate.charAt(6)) == false || isNumber(strDate.charAt(7)) == false || strDate.charAt(2) != "/" || strDate.charAt(5) != "/")
	{
		var obj = document.getElementById("error_message");
	
		obj.innerHTML = '<span class="error">Please correct the date format (mm/dd/yy).</span>';
		document.data1.elements["*Delivery_Date"].focus();
		
		return false;	
	}
	return true;
}


function CheckEmail()
{
	var strEmail = document.data1.elements["*Email"].value;
	
	if(strEmail.indexOf('@') != -1 && strEmail.indexOf('.') != -1 )
	{
		return true;		
	}
	else
	{
		var obj = document.getElementById("error_message");
	
		obj.innerHTML = '<span class="error">Please correct the email address.</span>';
		document.data1.elements["*Email"].focus();
		
		return false;		
	}
	
}

function printContent() {
    if (document.getElementById != null) {
        var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><HTML>\n<HEAD>\n';

        if (document.getElementsByTagName != null) {
            //var headTags = document.getElementsByTagName("head"); 

            //if (headTags.length > 0) 
            //html += headTags[0].innerHTML;

            html += '<TITLE>\n';
            var TitleTags = document.getElementsByTagName("pageTitle");
            if (TitleTags.length > 0) {
                html += TitleTags[0].innerHTML;
            }

            html += '\n</TITLE>';
            html +='\n<link href="css/print.css" rel="stylesheet" type="text/css" />';
            html += '\n</HE' + 'AD>\n<BODY style="background:none;">\n';
            //html += '<div id="printmain" style="width:800px; height:auto;background-color:#FFFFFF;color:black;"><div id="content1" style="position:relative:top:0px;left:0px;width:630px;height:auto;padding-top:0px;color:black;">'
            html += '<h3>Play Network, Inc.</h3>';
            var printPageElem = document.getElementById("content_padding");

            if (printPageElem != null) {
                
                html += printPageElem.innerHTML;
            }
            else {
                return;
            }
            html += '<br />';
            //html += '<span class="regular-text">© Copyright 2009 PlayNetwork, Inc. All rights reserved.<br /><br /></span>';
            html += '</div><br /><img src="../images/global/clear.gif" width="799" height="1"></div>'
            html += '\n</BO' + 'DY>\n</HT' + 'ML>';

            var printWin = window.open("", "printFriendly");
            printWin.document.open();
            printWin.document.write(html);
            printWin.print();
            printWin.document.close();

        }
        else {
            alert("Sorry, the printer friendly feature works\nonly in javascript enabled browsers.");
        }
    }


    function login() {
        window.open("resources/login.asp", "login", "height=257, width=320, toolbars=0");
    }




    function OpenPopup(strPopupName) {
        document.getElementById(strPopupName).style.visibility = "visible";
    }

    function ClosePopup(strPopupName) {
        document.getElementById(strPopupName).style.visibility = "hidden";
    }



    function ShowHide(intNum, strName, strName2) {
        var obj = document.getElementById(strName);
        var obj2 = document.getElementById(strName2);
        var obj3 = document.getElementById("bot_red_box");

        if (intNum == 1) {
            obj.style.display = "block";
            obj2.style.height = "140px"
            obj3.style.top = "200px";
        }
        else {
            obj.style.display = "none";
            obj2.style.height = "50px"
            obj3.style.top = "40px";
        }
    }


    function CollapseExpand(intNum, strName) {

        var obj = document.getElementById(strName);

        if (intNum == 1) {
            obj.style.display = "block";
        }
        else {
            obj.style.display = "none";
        }
    }


    function isNumber(sText) {
        var ValidChars = "-0123456789.";
        var IsNumber = true;
        var Char;


        for (i = 0; i < sText.length && IsNumber == true; i++) {
            Char = sText.charAt(i);
            if (ValidChars.indexOf(Char) == -1) {
                IsNumber = false;
            }
        }
        return IsNumber;

    }


    function CheckForInt(val, strName) {
        if (!isNumber(val)) {
            document.getElementById(strName).value = "";
            document.getElementById("not_numeric").style.visibility = "visible";
            return false;
        }
        else {
            return true;
        }
    }
}
