﻿document.write("<link rel=\"shortcut icon\" href=\"http://simg.gpotato.eu/common/favicon.ico\" />");

function FnGetObjById(sID, obj){
	if(!obj) obj = document;

	return document.getElementById(sID);
}

/*=============================================================================
use : flash write
@Param : string Object URL, int Width, int Height[, string Variable, string Background Color, string Window Mode]
=============================================================================*/
function ObFlashString(sObjURL, nWidth, nHeight, sVars, sBgColor, sWinMod, sObjId)
{
    if (sObjId == null || sObjId == "") sObjId = sObjURL.split("/")[sObjURL.split("/").length - 1].split(".")[0];
    if (sVars == null) sVars = '';
    if (sBgColor == null) sBgColor = '#FFFFFF';
    if (sWinMod == null) sWinMod = 'transparent';

    // flash code definition
    var flashStr = "	<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'";
    flashStr += "			codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'";
    flashStr += "			width='" + nWidth + "'";
    flashStr += "			height='" + nHeight + "'";
    flashStr += "			id='" + sObjId + "'";
    flashStr += "			align='middle'>";

    flashStr += "		<param name='allowScriptAccess' value='always' />";
    flashStr += "		<param name='transparent' value='true' />";
    flashStr += "		<param name='movie' value='" + sObjURL + "' />";
    flashStr += "		<param name='FlashVars' value='" + sVars + "' />";
    flashStr += "		<param name='wmode' value='" + sWinMod + "' />";
    flashStr += "		<param name='menu' value='false' />";
    flashStr += "		<param name='quality' value='high' />";
    flashStr += "		<param name='bgcolor' value='" + sBgColor + "' />";


    flashStr += "		<embed src='" + sObjURL + "'";
    flashStr += "		       flashVars='" + sVars + "'";
    flashStr += "		       wmode='" + sWinMod + "'";
    flashStr += "		       menu='false'";
    flashStr += "		       quality='high'";
    flashStr += "		       bgcolor='" + sBgColor + "'";
    flashStr += "		       width='" + nWidth + "'";
    flashStr += "		       height='" + nHeight + "'";
    flashStr += "		       name='" + sObjId + "'";
    flashStr += "		       align='middle'";
    flashStr += "		       allowScriptAccess='always'";
    flashStr += "		       type='application/x-shockwave-flash'";
    flashStr += "		       pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    flashStr += " </object>";

    // flash code print
    return flashStr;
}


/*=============================================================================
use : flash write
@Param : string Object URL, int Width, int Height[, string Variable, string Background Color, string Window Mode]
=============================================================================*/
function ObFlashWrite(sObjURL, nWidth, nHeight, sVars, sBgColor, sWinMod, sObjId)
{
    document.write(ObFlashString(sObjURL, nWidth, nHeight, sVars, sBgColor, sWinMod, sObjId));
}

function FnGetObjByClassName(element, tagname, classname) {
	var alldescendants = (element || document.body).getElementsByTagName(tagname);
	for(var i=0; i<alldescendants.length; i++) {
		if(classname == null || alldescendants[i].className.indexOf(classname) > -1) {
			return alldescendants[i];
		}
	}
	return null;
}

function FnGetArrByClassName(element, tagname, classname) {
	var descendants = new Array();
	var alldescendants = (element || document.body).getElementsByTagName(tagname);
	for(var i=0; i<alldescendants.length; i++) {
		if(classname == null || alldescendants[i].className.indexOf(classname) > -1) {
			descendants.push(alldescendants[i]);
		}
	}
	return descendants;
}

function FnShowStatus(sType)
{
	FnGetObjById("DivLayout").style.display = "block";
}

function FnGetObjXMLHttpRequest() 
{

    var objReq = false;
    if (window.XMLHttpRequest)
	{
        objReq = new XMLHttpRequest();
    } else if (window.ActiveXObject) 
	{
        try 
		{
            objReq = new ActiveXObject("Msxml2.XMLHTTP");
        } 
		catch (e1) 
		{
            try
			{
                objReq = new ActiveXObject("Microsoft.XMLHTTP");
            } 
			catch (e2)
			{
                return null;
            }
        }
    }
    return objReq;
}

function FnGetCommonHtml(sUrl)
{
	var objReq = FnGetObjXMLHttpRequest();
	objReq.open("GET", sUrl, false);
	objReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	objReq.setRequestHeader("Cache-Control","no-cache, must-revalidate");
	objReq.setRequestHeader("Pragma","no-cache");
	//objReq.send("", true);
    objReq.send("");

	document.write(objReq.responseText);
}

function FnOpenViewer(sUrl, nW, nH)
{
	try
	{
		var w=window.open(sUrl, "VIEWER", "modal=1, width=" + nW + ", height=" + nH);
	}
	catch(e)
	{
		var w=window.open(sUrl, "VIEWER", "modal=1, width=" + nW + ", height=" + nH);
		w.focus();
	}
}

function addHandler(id, eventName, handler, elem)
{
    var elem = elem || document.getElementById(id);

    if (id == "window") elem = window;

    if (null == elem || typeof (elem) == 'undefined')
        return;

    if (elem.addEventListener)
    {
        elem.addEventListener(eventName, handler, false);
    }
    else if (elem.attachEvent)
    {
        elem.attachEvent("on" + eventName, handler);
    }
    else
    {
        var origHandler = elem["on" + eventName];
        if (origHandler)
        {
            var h = new object();
            h.origHandler = origHandler;
            h.newHandler = handler;
            h.both = new function(e) { this.origHandler(e); this.handler(e); };
            elem["on" + eventName] = h.both;
        }
        else
        {
            elem["on" + eventName] = handler;
        }
    }
}

function ShowNewsIframe(){
    $("#content_loader").css("visibility","hidden");
    $("#news_content").css("visibility","visible");
}
function HideNewsIframe(){
    $("#news_content").css("visibility","hidden");
    $("#content_loader").css("visibility","visible");
}

function submitPoll(name)
{
    var value = -1;
    var radios = eval("document.forms.POLLFRM." + name);

    for (var i = 0; i < radios.length; i ++)
    {
        if (radios[i].checked)
        { 
            value = radios[i].value;
            document.forms.POLLFRM.submit();
        }
    }
    if(value == -1)
    {
        alert("Merci de choisir une réponse");
        return false;
    }   
}


$(function()
{
    $("#content .sub_tab a").click(function()
    {
        $(this).blur().
        parent().addClass("visible");
        $("#content .sub_tab .visible").not($(this).parent()).removeClass("visible");
    });
});


// ============================================================================
//
// ============================================================================
$(document).ready(function() {
    $("#left_menu_topupgpotato, #left_menu_visitshop").click(function() {
        return RequestLoginIfNotAuthenticated(this.href, false);
    });
});