﻿function ActCMS() {
	this.majorVersion = "1";
	this.minorVersion = "0.0.1";
	this.releaseDate = "2006-08-15";
	this.popupW			= 640;
	this.popupH 		= 460;
	this.popupRef 		= null;
	this.popupUrl 		= null;
	
	this.lastGallery		= [];
	this.lastGalleryC		= 0;
}	

ActCMS.prototype.el = function (obj) {
	if (document.getElementById) return document.getElementById(obj);
	else if (document.all) return document.all[id];
}

ActCMS.prototype.cq = function (obj,zm) {
		
		var inp = obj.parentNode.firstChild;
		while (inp.nodeType != 1 || inp.tagName !='INPUT') inp = inp.nextSibling;
		
		var tmpIl = parseInt(inp.value,10);

		var reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {
			inp.value = tmpIl + zm - reszta;
		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { inp.value = tmpIl - reszta; }
			else {	inp.value = tmpIl + zm; }

		}

}

   
ActCMS.prototype.oW = function (obj,w,h,x,y,cent,rs,sb,mb,ab,nb) {
	if (sb == null) sb = 1;
	if (rs == null) rs = 1;
	if (w == null) w = this.popupW;
	if (h == null) h = this.popupH;
	if ((cent == null && x == null && y == null) || cent) {
		x = Math.floor((screen.availWidth-w)/2);
		y = Math.floor((screen.availHeight-h)/2);
	}
	
	if (obj.href.indexOf("page.php?")!=-1)	
		surl = obj.href+'&popup=1';
	else if (obj.href.match(/(.*)\/\d+\.html/)) 
		surl = obj.href.replace('.html',',popup,1.html');
	else if (obj.href.match(/(.*)\/rid\,\d+\.html/)) 
		surl = obj.href.replace('.html',',popup,1.html');
	else surl = obj.href;
	
	nid = parseInt(Math.random()*10000000);	
	
	if (this.popupRef == null || this.popupRef.closed || this.popupUrl != surl) 
		this.popupRef = window.open(surl,'pp'+nid,
		'scrollbars='+((sb)?'yes':'no') +
		',menubar='+((mb)?'yes':'no') +
		',resizable='+((rs)?'yes':'no') +
		',toolbar='+((nb)?'yes':'no') +
		',location='+((ab)?'yes':'no') +
		',left='+x+',top='+y+',width='+w+',height='+h
		);
	this.popupUrl = surl;
	this.popupRef.focus();
}

ActCMS.prototype.pZoom = function (path, title, params) {
	imageRef=window.open('','pZoom');
	imageRef.document.writeln(
    '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">'
    +'<head>'
    +'<title>' + title + '</title>'
    +'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'
    +'<link rel="Shortcut Icon" type="image/png" href="img/favicon.png" />'
    +'</head>'
    +'<body bgcolor="black" onLoad="self.focus()">'
    +'<table cellspacing=0 cellpadding=0 border=0 width=100% height=100%>'
    +'<tr valign=middle><td align=center>'
        +'<img src="' + path + '" title="' + title + '" alt="ZdjĂ„?cie:' + title + '" />'
    +'</td></tr>'
    +'<tr valign=bottom><td align=center>'
    +'<a href="javascript:window.close()">Zamknij okno</a>'
    +'</td></tr>'
    +'</table>'
    +'<script type="text/javascript">'
    +'<!--'
    +'var ttop=(screen.height-320)/2'
    +'var lleft=(screen.width-270)/2'
    +'self.moveTo(lleft,ttop)'
    +'// -->'
    +'</script>'
    +'</body></html>'
	)

	imageRef.document.close();
}

ActCMS.prototype.rotateGallery = function(imgid) {
	++this.lastGalleryC;
	if( !this.lastGallery[this.lastGalleryC] ) this.lastGalleryC = 1;
	this.el(imgid).src = this.lastGallery[this.lastGalleryC];
	setTimeout("actCMS.rotateGallery('"+imgid+"')",3000);
}

ActCMS.prototype.flash = function(src,x,y,ver,name,opcja) {
	
	if (ver == null) ver = 6;
	if (name == null) name = Math.floor(Math.random()*10000);
	
	document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ver+',0,0,0"');
	document.write ('width='+x+' height='+y+' id="'+name+'">');
	document.write ('<param name=movie value="'+src+'">');
	document.write ('<param name=quality value=high>');

	if (opcja == 'transparent') 
		document.write ('<param name="wmode" value="transparent">');
	if (opcja == 'opaque') 
		document.write ('<param name="wmode" value="opaque">');
		
	document.write ('<param name="swliveconnect" value="true">');
	document.write ('<embed src="'+src+'" quality="high" width="'+x+'" height="'+y+'"');
	document.write (' type="application/x-shockwave-flash"');
	document.write (' pluginspage="http://www.macromedia.com/downloads/"');
	document.write (' name="'+name+'" ');
	if  (opcja == 'opaque') document.write (' wmode="opaque"');
	if  (opcja == 'transparent') document.write (' wmode="transparent"');
	document.write (' swliveconnect="true">');
	document.write ('</embed>');
	document.write ('</object>');
}
String.prototype.urlencode = function() {
	s = this; //escape, encodeURI
	s = s.replace(/\./g,'%2E')
	s = s.replace(/\//g,'%2F')
	s = s.replace(/\-/g,'%2D')
	s = s.replace(/\*/g,'%2A')
	s = s.replace(/\%/g,'*')
   return s;
}
String.prototype.isourlencode = function() {
	//s = encodeURI(this); //escape
	s = this;
	
	
	var specIn = [];
	var specOut = [];
	
	for (a in specIn) s = s.replace(specIn[a],specOut[a]);	
	
	
	
	
	
	s = s.replace(/\./g,'%2E')
	s = s.replace(/\//g,'%2F')
	s = s.replace(/\-/g,'%2D')
	s = s.replace(/\*/g,'%2A')
	s = s.replace(/\%/g,'*')
   return s;
}

/*
Array.prototype.search = function(v) {
	for(a in this) {if (this[a] == v) return true;}
	return false;
}
*/

ActCMS.prototype.addLoadEvent = function(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}


actCMS = new ActCMS();
