﻿/* 

	$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 */