﻿function SetWebSite()
{
    var Flash = false;
    if(FlashControlVersion() != '')
    {
        Flash = true;
    }
    if (Flash)
    {
        swfobject.embedSWF("Flash/PiSocialMedia.swf", "main", '100%', '100%', "9.0.115", null, false, null, attributes);		
		swffit('website', 1000, 600, 2000, 2000);
		swfobject.addDomLoadEvent(runSetup);
//		if(getInternetExplorerVersion() != -1)
//		    document.body.scroll = "no";
    }
    else
    {
        ShowDiv();
    }
}
function CheckFlash()
{
    if(FlashControlVersion() == '')
    {
        alert('There is no Flash player in the current browser.');
        return false;
    }
    else
    {
        return true;
    }
}
function ShowDiv()
{
    document.getElementById('main').style.display = '';
}
function runSetup() {
			if (document.getElementById('website')) {				
				switchstyle('');
			}
		}
function getInternetExplorerVersion()
{
  var rv = -1;
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function switchstyle(s) 
{
    if (!document.getElementsByTagName) 
        return;
	var el = document.getElementsByTagName("link");
	for (var i = 0; i < el.length; i++ ) 
	{
		if (el[i].getAttribute("rel").indexOf("style")!= -1 && el[i].getAttribute("title")) 
		{
			el[i].disabled = true;
			if (el[i].getAttribute("title") == s) 
			    el[i].disabled = false;
		}
	}
}
var params = {
	menu: "false",
	bgcolor: '#E7E6E2',
	wmode: "transparent"
};
var attributes = {
	id: "website",
	name: "website"
};

function FlashControlVersion()
{
	var version = '';
	var axo;
	var e;

	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "WIN 6,0,21,0";
			axo.AllowScriptAccess = "always";
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}
function GetCurrentFlashPageID(PageID,Title)
{
    if(Title != null && Title != '')
    {
        if(getInternetExplorerVersion() != '-1')
        {
            var newtitlenode = document.createElement("title");
            var newtext = document.createTextNode(Title);
            newtitlenode.appendChild(newtext);
            var headnode = document.getElementsByTagName("head").item(0);
            var oldtitlenode = document.getElementsByTagName("title").item(0);
            headnode.replaceChild(newtitlenode,oldtitlenode);
            headnode = document.getElementsByTagName("head").item(0);
        }
        else
        {
            parent.document.title = Title;
        }
    }
    if(PageID != null && PageID != '')
    {
        location.hash = PageID;
    }
    else
    {
        location.hash = '';
    }
}
var XmlReq;
function GetAndChangePageContent(AjaxServerPageName)
{
    if(AjaxServerPageName != '')
    {
        CreateXmlReq();
        if(XmlReq)
	    {
		    XmlReq.onreadystatechange = HandleResponse;
		    XmlReq.open("GET", AjaxServerPageName,  true);
		    XmlReq.send();
	    }
	}
}
function FillPage(pageElements)
{
    document.write = pageElements;
}
function HandleResponse()
{
    if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
		    FillPage(XmlReq.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function CreateXmlReq()
{
    try
	{
		XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlReq = null;
		}
	}
	if(!XmlReq && typeof XMLHttpRequest != "undefined") 
	{
		XmlReq = new XMLHttpRequest();
	}
}
function validateEmail( strValue) 
{
    var objRegExp = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

    return objRegExp.test(strValue);
}
function DisplayDiv(control1,control2)
{
    var divs = document.getElementsByTagName('div');
    for(var count=0;count<divs.length;count++)
    {
        if(divs[count].id.indexOf('div_') > -1)
        {
            if(divs[count].id != control1 && divs[count].id != control2)
            {
                divs[count].style.display = 'none';
            }
            else
            {
                divs[count].style.display = '';
            }
        }
    }
}