﻿/* 

	$Id: scripts.js,v 1.17.2.4.2.6 2007/03/12 11:39:04 pawelki Exp $ 

*/

var flashQuality = 'auto';

function BuildFlash(swf, width, height, flashvars, wmode) {
	var str  = '<object type="application/x-shockwave-flash" data="'+ swf +'" width="'+ width +'" height="'+ height +'">';
		str += '<param name="movie" value="'+ swf +'" />';
		str += '<param name="flashvars" value="'+ flashvars +'"/>';
		str += '<param name="wmode" value="'+ wmode +'"/>';
		str += '<param name="allowScriptAccess" value="always" />';
		str += '<param name="quality" value="'+ flashQuality +'" />'
		str += '<param name="menu" value="false" />'
		str += '</object>';

	if (swf != '')
		document.write(str);
	else
		return;
		//document.write('SWF undefined');
}

function BuildFlash123(swf, width, height, flashvars, wmode) {
		var str  = '<object type="application/x-shockwave-flash" data="'+ swf +'" width="'+ width +'" height="'+ height +'">';
			str += '<param name="movie" value="'+ swf +'" />';
			str += '<param name="flashvars" value="'+ flashvars +'"/>';
			str += '<param name="wmode" value="'+ wmode +'"/>';
			str += '<param name="allowScriptAccess" value="always" />';
			str += '<param name="quality" value="'+ flashQuality +'" />'
			str += '<param name="menu" value="false" />'
			str += '<param name="bgcolor" value="#990000"/>'
			str += '</object>';

		if (swf != '')
			document.write(str);			
		else
			return;
}

function BuildFlashVideo () {
var s = '		<object width="365" height="240" id="flash" data="../_files/cokelivefreshnoise/video.swf" type="application/x-shockwave-flash">'+
		  '<param name="allowScriptAccess" value="always" />'+
		  '<param name="movie" value="../_files/cokelivefreshnoise/video.swf" />'+
		  '<param name="quality" value="high" />'+
		  '<param name="bgcolor" value="#ffffff" /></object>';
document.write(s);	
}

function BuildFlash123id(id, swf, width, height, flashvars, wmode) {
		var str  = '<object type="application/x-shockwave-flash" name="'+id+'" id="'+ id +'" data="'+ swf +'" width="'+ width +'" height="'+ height +'">';
			str += '<param name="movie" value="'+ swf +'" />';
			str += '<param name="flashvars" value="'+ flashvars +'"/>';
    		str += '<param name="wmode" value="'+ wmode +'"/>';
			str += '<param name="allowScriptAccess" value="always" />';
			str += '<param name="quality" value="'+ flashQuality +'" />'
			str += '<param name="menu" value="false" />'
			str += '<param name="bgcolor" value="#990000"/>'
			str += '</object>';

		if (swf != '')
			document.write(str);
		else
			return;
}


function BuildFlashInner(swf, width, height, flashvars, wmode) {
	var str  = '<object type="application/x-shockwave-flash" data="'+ swf +'" width="'+ width +'" height="'+ height +'">';
		str += '<param name="movie" value="'+ swf +'" />';
		str += '<param name="flashvars" value="'+ flashvars +'"/>';
		str += '<param name="wmode" value="'+ wmode +'"/>';
		str += '<param name="allowScriptAccess" value="always" />';
		str += '<param name="quality" value="'+ flashQuality +'" />'
		str += '<param name="menu" value="false" />'
		str += '</object>';

	if (swf != '')
		return str;
	else
		return 0;
		//return 'SWF undefined';
}

function reloadMe() {    
    self.location.reload();
}

function parseArgsFromA(str) {
	var re = /<a id="([\w\W\s]*)" href="([\w\W\s]*)">([\w\W\s]*)<\/a>/;
	if ( re.test(str) ) {
		var tmp = re.exec(str);
		return [tmp[2],tmp[3],tmp[1]];
	} else 
		return new Array();
}

function dropHTML(str) {
	var tmp = str.replace(/(<([^>]+)>)/ig, ''); 
	return tmp;
}

function hideTutorial() {
	var iObj = document.getElementById('fakeImg');
	var tObj = document.getElementById('jtd');
	var stObj = document.getElementById('jtdSmall');
	
	iObj.src = '/Sklep/HowThisWork.aspx';
	tObj.style.display = 'none';
	stObj.style.display = 'block';
}

var _xx_url='';
var _xx_wname='';
var _xx_params='';
function xx_wopen() {
        if (typeof(Error)!='undefined') {
                eval("try { if(_xx_url!='') window.open(_xx_url,_xx_wname,_xx_params); _xx_url=''; } catch(_xx_ev) {}");
        } else {
                if(_xx_url!='') window.open(_xx_url,_xx_wname,_xx_params); _xx_url='';
        }
}

function my_window_open(url,wname,params) {
        if (typeof(Error)!='undefined') {
                eval("try { _xx_wo=window.open(url,wname,params); } catch(_xx_ev) {}");
        } else {
                _xx_wo=window.open(url,wname,params);
        }
        if(!_xx_wo) {
                _xx_url = url;
                _xx_wname = wname;
                _xx_params = params;
                if (document.attachEvent) document.attachEvent("onclick", xx_wopen);
                else if(document.addEventListener) document.addEventListener("click", xx_wopen, false);
        }
}

var popWin = null;
function popUp(src, w, h, name) {
	if (name == 'undefined' || !name) name='icokePopUp';
	my_window_open(src, name, 'toolbar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,width='+eval(w)+',height='+eval(h)+',menubar=no');

/*
	if (!popWin || popWin.closed) {
		popWin = window.open(src, 'popup', 'toolbar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,width='+eval(w)+',height='+eval(h)+',menubar=no')
	} else {
		popWin.document.location.href = src;
	}
	popWin.focus();
*/
}

function popUpScroll(src, w, h, name) {
	if (name == 'undefined' || !name) name='icokePopUp';
	my_window_open(src, name, 'toolbar=no,scrollbars=yes,resizable=no,status=no,location=no,directories=no,width='+eval(w)+',height='+eval(h)+',menubar=no');

/*
	if (!popWin || popWin.closed) {
		popWin = window.open(src, 'popup', 'toolbar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,width='+eval(w)+',height='+eval(h)+',menubar=no')
	} else {
		popWin.document.location.href = src;
	}
	popWin.focus();
*/
}

 
 function popUpImg(s) {
   var x=0; 
   var y=0; 
   var pWin=0;
   if (s == '') return;
   var str = '<ht' + 'ml><he' + 'ad><ti' + 'tle>Image</ti' + 'tle></he'+'ad><bo'+'dy bgcolor="#FFFFFF" topmargin="0" leftmargin="0" onload="var widthImage = document.getElementById(\'image\').width+30; if (widthImage > 1054) { widthImage = 1054; } var heightImage = document.getElementById(\'image\').height + 56; if ( heightImage > 824) { heightImage = 824; } self.resizeTo(widthImage,heightImage);"><a href="javascript:self.close()"><img id="image" src='+s+' border="0"></a></bo' + 'dy></ht' + 'ml>';
   if (!pWin || pWin.closed) {
   pWin = window.open('','pWin','dependent=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no,width=1,height=1,menubar=no,left=100,top=100')
}
pWin.document.open();
pWin.document.write(str);
pWin.document.close();
pWin.focus();
}

function openFilePopup(filePath) {
   var x=0; 
   var y=0; 
   var pWin=0;
   if (filePath == '') return; 
   if (!pWin || pWin.closed) pWin = window.open('flashGame.html?filePath='+filePath,'pWin','dependent=yes,resizable=no,scrollbars=no,status=no,toolbar=no,width=640,height=480,menubar=no,left='+(screen.availWidth/2-640/2)+',top='+(screen.availHeight/2-480/2))
	pWin.focus();
}

function writeFlash(filePath) {
   var flash = '<object width="640" height="480" align="" id="flashgame" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">';
   flash += '<param name="movie" value="'+filePath+'"/>';
   flash += '<param name="quality" value="high"/>';
   flash += '<param name="allowNetworking"  value="internal"/>';
   flash += '<param name="enableJavascript" value="false"/>';
   flash += '<param name="allowScriptAccess" value="never"/>';
   flash += '<param name="bgcolor" value="transparent"/>';
   flash += '<param name="wmode" value="transparent"/>';
   flash += '<param name="menu" value="false"/>';
   flash += '<embed width="640" height="480" align="" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" swliveconnect="true" name="flashgame" wmode="transparent" bgcolor="transparent" quality="high" src="'+filePath+'" allowNetworking="internal" enableJavascript="false" allowScriptAccess="never"/>';
   flash += '</object>';
   document.write(flash);
}

 // Image Rotator
function getRandomImage(imagesArr){
    var count = imagesArr.length;
    if (count){
        var r=Math.floor(Math.random()*count);
        return imagesArr[r];
    } else
        return null;
}
// /Image Rotator

// Auction Clock
function getQueryParamValue(param){
	var q = document.location.search || document.location.href.hash;
	if(q){
		var startIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
		if (q.length > 1 && startIndex > -1) {
			return q.substring(q.indexOf("=", startIndex)+1, endIndex);
		}
	}
	return "";
}
// /Auction Clock

//tabSwitcher-Zespoly
var poz = '0';
var menuBoxes = new Array('mb1','mb2','mb3','mb4');
var tabs = new Array ('mtA','mtB','mtC','mtD');
function switchTabTo(px){
	for (var i=0;i<tabs.length;i++) {
		var obj = document.getElementById(tabs[i]);
		obj.className = 'tabHide'; 
		menuBoxOut(i, true);
	}
	var obj = document.getElementById(tabs[px]);
	obj.className = 'tabShow';
	poz=px;
	menuBoxOver(px);
}
function menuBoxOver(px){
		obj = document.getElementById(menuBoxes[px]);
		obj.className = 'mSel';
}
function menuBoxOut(px, all){
	obj = document.getElementById(menuBoxes[px]);
	if (!all){if (px!=poz) obj.className = 'm';}
	else obj.className = 'm';
}
// /tabSwitcher-Zespoly


function showId(id){
document.getElementById(id).style.display='block'; 
}
function hideId(id){
document.getElementById(id).style.display='none'; 
}


/* background */
function resizeBg() {
/*
	A = 132;
	B = 190;
	var min = (A + 3*B);
	var myHeight = document.getElementById("container").offsetHeight; 
	var R = (myHeight - A)
	var Rx=(Math.ceil(R/B));
	if (myHeight < min)	newH=min;
	else if((R % B)>0) newH = (A + B*Rx);
	else newH = myHeight;	
	var bgR = document.createElement("div");
	bgR.innerHTML = BuildFlashInner('../_files/Sklep/rightSide.swf', '73', newH, '', 'transparent');
	document.getElementById("panelBgRight").appendChild(bgR);
	var bgL = document.createElement("div");
	bgL.innerHTML = BuildFlashInner('../_files/Sklep/leftSide.swf', '73', newH, '', 'transparent');
	document.getElementById("panelBgLeft").appendChild(bgL);	
	document.getElementById("container").style.height = newH + "px";
*/
}
/* /background */

var tabs = new Array('ctl00_cphHiddenItems_CtrlLogon1_loginForm','ctl00_cphHiddenItems_CtrlRegister1_divMain');
var p = 0;
function changeTab(px){
p=px;
for (i=0;i<tabs.length;i++) {
	obj = document.getElementById(tabs[i]);
	
	if (i == p) {
		obj.style.display = 'block';
	}
	else {
		obj.style.display = 'none'; 
	}
}
}

/* community tips */

	var tipT = null;

	function showTip(id) {
		clearTimeout(tipT);
		var obj = document.getElementById(id);
		//obj.parent.style.backgroundColor = '#ADA89D';
		obj.style.display = 'block';
		tipT = setTimeout('hideTip(\''+id+'\')',1000);
	}

	function hideTip(id) {
		clearTimeout(tipT);
		var obj = document.getElementById(id);
		obj.style.display = 'none';
	}
/* /community tips */



/* nowy sklep */


    function expandFormsPanel() {
        var formsPanel = document.getElementById('formsWrapper');
        formsPanel.style.width = '440px';
        formsPanel.style.height = '480px';
        formsPanel.style.top = '30px';
    }

    function collapseFormsPanel() {
        var formsPanel = document.getElementById('formsWrapper');
        formsPanel.style.top = '0px';
        formsPanel.style.width = '1px';
        formsPanel.style.height = '1px';
    }

    function showLogonPanel() {
        expandFormsPanel();
        document.getElementById('flashMainMenuForms').showLogonPanel();
    }
    
    function showRegistrationPanel() {
        expandFormsPanel();
        document.getElementById('flashMainMenuForms').showRegistrationPanel();
    }
    
    function showThankYouPanel() {
        expandFormsPanel();
        document.getElementById('flashMainMenuForms').showThankYouPanel();
    }
    
    
/* /nowy sklep */
    function IfKeyEnterToClickAnchorElement(btnID,e) {
        if (e.keyCode == 13)
        {
            var buttonOk = document.getElementById(btnID);
            // submit the form by programmatically clicking the specified button
            document.location.href = buttonOk.href;
            
            // cancel the default submit
            //e.cancelBubble is supported by IE - this will kill the bubbling process.
            e.cancelBubble = true;
            e.returnValue = false;

            //e.stopPropagation works only in Firefox.
            if (e.stopPropagation) 
            {
                    e.stopPropagation();
                    e.preventDefault();
            }
            return false;
        }
    }
    
    function IfKeyEnterToClickElement(btnID,e)
    {
        if (e.keyCode == 13)
        {
            var buttonOk = document.getElementById(btnID);
            // submit the form by programmatically clicking the specified button
            buttonOk.click();
            
            // cancel the default submit
            //e.cancelBubble is supported by IE - this will kill the bubbling process.
            e.cancelBubble = true;
            e.returnValue = false;

            //e.stopPropagation works only in Firefox.
            if (e.stopPropagation) 
            {
                    e.stopPropagation();
                    e.preventDefault();
            }
            return false;
        }
    }
    
    
    
function MyClickElementVersionMSAJAX(btnID)
{
    var buttonOk = document.getElementById(btnID);
    document.location.href = "javascript:__doPostBack('" + buttonOk.name + "','')";
    return false;
}

function MyClickElement(btnID)
{
    var buttonOk = document.getElementById(btnID);
    buttonOk.click();
    return false;
}

function MyClickAnchorElement(btnID)
{
    var buttonOk = document.getElementById(btnID);
    document.location.href = buttonOk.href;
    return false;
}    

function openpopup(url) {

		var theURL=url;
		var winName='popup';
		var width=500;
		var height=580;
		var topY=(screen.height-height)/2;
		var leftX=(screen.width-width)/2;
		var features='innerWidth=' + width+',innerHeight='+height+',width=' + width+',height='+height+',top='+topY+',left='+leftX+',resizable=0,srollbars=0';

	
	    var popup=window.open(theURL,winName,features);
		popup.focus();
}
//--------------------------------------------------------------------------------

String.prototype.IsNullOrEmptyOrUndefined = function() {
    if (this == undefined || this == null || this == '')
        return true;
    else
        return false;
}

function IsNullOrEmptyOrUndefined(object) {
    if (object == undefined || object == null || object == '')
        return true;
    else
        return false;
}

function Format(text) {
    for (i = 1; i < arguments.length; i++) {
        text = text.replace('{' + (i - 1) + '}', arguments[i]);
    }
    return text;
}

function CreateCookie(cookieName, cookieValue)
{
    CreateCookie(cookieName, cookieValue, 0);
}

function CreateCookie(cookieName, cookieValue, expiresInDays) 
{
    if (expiresInDays > 0)
    {
        var expiresDate = new Date();
        expiresDate.setTime(expiresDate.getTime() + (expiresInDays * 24 * 60 * 60 * 1000));
        document.cookie = Format('{0}={1}; expires={2}; path=/', cookieName, cookieValue, expiresDate.toGMTString());
    }
    else
        document.cookie = Format('{0}={1}; path=/', cookieName, cookieValue);    
}

function EraseCookie(cookieName) {
    var expiresDate = new Date();

    document.cookie = Format('{0}={1}; expires={2}; path=/', cookieName, '', expiresDate.toGMTString());
}

function ReadCookie(cookieName) {
    var nameEQ = cookieName + "=";
    var cookies = document.cookie.split(';');

    for (var i = 0; i < cookies.length; i++) {
        while (cookies[i].charAt(0) == ' ')
            cookies[i] = cookies[i].substring(1, cookies[i].length);

        if (cookies[i].indexOf(nameEQ) == 0)
            return cookies[i].substring(nameEQ.length, cookies[i].length);
    }
    return null;
}
//--------------------------------------------------------------------------------

var INTERVAL_HANDLER_ID;
function CheckCookie(cookieName, intervalInMillisecinds) 
{
    if (IsNullOrEmptyOrUndefined(INTERVAL_HANDLER_ID))
        INTERVAL_HANDLER_ID = setInterval('CheckCookie(\''+cookieName+'\','+intervalInMillisecinds+');', intervalInMillisecinds);

    var cookieValue = ReadCookie(cookieName);

    switch (cookieValue) 
    {
        case 'ReloadWithoutQuery':
            EraseCookie(cookieName);
            clearInterval(INTERVAL_HANDLER_ID);
            INTERVAL_HANDLER_ID = null;
            window.location.replace(document.location.href.split("?")[0]);
            break;

        case 'Reload':
            EraseCookie(cookieName);
            clearInterval(INTERVAL_HANDLER_ID);
            INTERVAL_HANDLER_ID = null;
            window.location.replace(document.location.href);
            break;

        case 'Alert':
            EraseCookie(cookieName);
            clearInterval(INTERVAL_HANDLER_ID);
            INTERVAL_HANDLER_ID = null;
            alert('ok');
            break;

        case 'Close':
            EraseCookie(cookieName);
            clearInterval(INTERVAL_HANDLER_ID);
            INTERVAL_HANDLER_ID = null;
            window.myLytebox.end();
            break;
            
        default:
    }
}
//--------------------------------------------------------------------------------