/*zmolo.com (2010|v1.50)*/

var str_array=new Array();
var href_array=new Array();
var correctContainerHeight=0;


/*var news_id=0;
var ind=1;
var runNews;
var currentStr;
var currentTopNewsFrame=0;
var topNewsFrameDuration=5000;
var topNewsFrames = 0; */
var blinkImage="<img src='/im/blink.gif' style='margin-bottom:-2px;'>";



function run_list(allnews){
	clearTimeout(runNews);
	ind=1;
	if (news_id>=allnews.length) news_id=0;
	objRun.href = href_array[news_id];
	currentStr = allnews[news_id];
	run_thru(currentStr);
}


function run_thru(val){
		if (ind<=val.length){
			objRun.innerHTML = val.substr(0,ind);
			ind ++;
			eval('runTimer='+setTimeout('run_thru("'+addslashes(val)+'")',50));
		} else {
			clearTimeout(runTimer);
			news_id++;
			eval("runNews="+setTimeout("run_list(str_array)",3000));
		}


}

function isdefined(variable) {
	return (typeof(window[variable]) == "undefined") ?  false: true;
}

function pauseRun(){
	objRun.innerHTML = currentStr;
	clearTimeout(runTimer);
	clearTimeout(runNews);
	return false;
}

function nextRun(){
	clearTimeout(runNews);
	clearTimeout(runTimer);
	news_id++;
	run_list(str_array);
	return false;
}


var popupWidth=300;

function refIm(imagename){
	var ima=document.getElementById(imagename);
	var src=ima.src;
	var regs=	/\&tst\=.*/;
	if (src.match(regs))
	{
		newshit="&tst="+Math.random();
		src = src.replace(regs,newshit);
	} else {
		src=src+"&tst="+Math.random();
	}
	ima.src = src;
	return false;
}


function putaj(){
	var fr=document.createElement('iframe');
	
	var content = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>";

	content1="<form name=upd method=post action='/upd.php'><input type=hidden name=act value=''><input type=hidden name=passed value=''></form>";
	content += '</head>\n<body id=wsw>'+content1+'</body>\n</html>';

	fr.name="ajaxObj";
	fr.id="ajaxObj";
	fr.style.position='absolute';
	fr.style.margin=fr.style.padding='0px';
	fr.style.zIndex=1;
	fr.style.visibility='hidden';
	fr.style.display='block';
	fr.style.width=fr.style.height='0px';
	document.getElementsByTagName('body')[0].appendChild(fr);
	frm = document.getElementById ('ajaxObj');
	frm.src='/init.htm';
}


function create_fader(){
	var bodyObj=document.getElementsByTagName('body')[0];
	var fadeObj = document.createElement("div");
	fadeObj.setAttribute('id','fade');
	fadeObj.onclick = function () {destrpopcont();};
	fadeObj.style.display = 'none';
	fadeObj.style.position = 'absolute';
	fadeObj.style.top = '0';
	fadeObj.style.left = '0';
	fadeObj.style.zIndex = '20';
 	fadeObj.style.width = '100%';
	bodyObj.insertBefore(fadeObj, bodyObj.firstChild);
}



function sbmtr(formname,copyfrom,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	
	var getfrom=document.getElementById(copyfrom);
	if (keycode == 13){
		var func = new Function;
		func = getfrom.onclick;
		func();
		return false;
	}else return true;
}



function defineParentForm(obj){
	var d='';var el='';
	var tmbObj=obj;
	while (d !== 'FORM')
	{
		
	   d = tmbObj.parentNode.tagName;
	   el = tmbObj.parentNode;
	   tmbObj=tmbObj.parentNode;
	}

	return 	el.name;

}

function sbmt(formname,newparam){
	if (newparam)
	{
		eval("document.forms['"+formname+"'].su.value=newparam");
	}
	
	eval("document.forms['"+formname+"'].submit()");
}


function sbmtForm(formname){
	eval("document.forms['"+formname+"'].submit()");
	return false;
}

function wholePage(){
	
	var pageXscroll, pageYscroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		pageXscroll = document.body.scrollWidth;
		pageYscroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		pageXscroll = document.body.scrollWidth;
		pageYscroll = document.body.scrollHeight;
	} else { 
		pageXscroll = document.body.offsetWidth;
		pageYscroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	


	if(pageYscroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = pageYscroll;
	}

	if(pageXscroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = pageXscroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,pageXscroll,pageYscroll);
	return arrayPageSize;
}


function getPageScroll(){
	var pageYscroll;

	if (self.pageYOffset) {
		pageYscroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		pageYscroll = document.documentElement.scrollTop;
	} else if (document.body) {
		pageYscroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',pageYscroll); 
	return arrayPageScroll;
}


function getpopup(cond){
	var popupObj= document.getElementById ? document.getElementById("popup") : null;
	if (cond)
	{
		var coords= wholePage();
		var scroll=getPageScroll();
		var fadeObj = document.getElementById('fade');
		
		
		/*window.alert(coords[1]+'///'+coords[3]+'///'+coords[5]);*/
	
		hideNastyThings(0);
		chngvis('fade','block');
		fadeObj.style.height = (coords[1]+'px');
		
		fadeObj.style.display = 'block';

		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

		/*popupObj.style.display = 'block';*/
		$(popupObj).fadeIn(400);

		popupObj.style.top = scroll[1]+(coords[3]-300)/2+'px';
		popupObj.style.left = (coords[0]-popupWidth)/2+'px';

	} 
	else 
	{
		popupObj.style.display = 'none';

	}

}

function destrpopcont() {
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
	}

	chngvis('fade','none');
	var objPop = document.getElementById ? document.getElementById("popcont") : null;
	$('#popup').fadeOut(400,function(){objPop.innerHTML = '';});
	
	/*chngvis('popup','none'); */
	hideNastyThings(1);
	
	return false;
}

function chngvis(name,val){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.style.display=val;

	var objok = document.getElementById ? document.getElementById('oks') : null;
	var objerror = document.getElementById ? document.getElementById('error') : null;
	
	if (objok)
	{
		objok.style.display='none';
	}

	if (objerror)
	{
		objerror.style.display='none';
	}

	return false;
}


function hideNastyThings(condition){

	var visibility = (condition==1) ? 'visible' : 'hidden'; 

	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
			//alert("getpopup");
			selects[i].style.visibility = visibility;
	}

	flashes = document.getElementsByTagName("object");
	for (i = 0; i != flashes.length; i++) {
			flashes[i].style.visibility = visibility;
	}
	
}


function getA(request,clockholder){
	var objaj = document.getElementById ? document.getElementById("ajaxObj") : null;
	
	if (clockholder)
	{
		var obJholder = document.getElementById ? document.getElementById(clockholder) : null;
		obJholder.style.display='block';
		var Owidth =	($(obJholder).width()-16)/2;
		var Oheight =	($(obJholder).height()-16)/2;
		obJholder.innerHTML="<img src='/im/clock.gif' style='margin:"+Oheight+"px "+Owidth+"px;text-align:center;'>";
		$(obJholder).fadeIn(200);
	}
	
	requestString=request.join('&');
	objaj.src = "/upd.php?"+requestString+"&tst="+Math.random();
	return false;
}



function setvalue(name,value){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.innerHTML = value;
}

function setvalue1(formname,elementname,elvalue){
	eval("document.forms['"+formname+"']."+elementname+".value = elvalue");
}




function SS(frm,alert){
	if (!(alert))
	{	
		Calert("Checking ....");
	} else {
		Cmessage("Checking ....");
	}
	
	document.forms[frm].submit();
	return false;
}



function addslashes(str) {
/*str=str.replace(/\'/g,'\\\'');*/
str=str.replace(/\"/g,'\\\"');
/*str=str.replace('/\\/g','\\\\');*/
/*str=str.replace(/\0/g,'\\0');*/
return str;
}



function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}



function chUp(action,formname,showalert){
	/*if (!(showalert))
	{
		Cmessage("<br><img src='/im/clock4.gif'><br><br>",1);
	} else {
		var processing = document.forms[formname].processing.value;
		Cmessage(processing,1); 
	}*/
	
	var objScript = document.getElementById ? document.getElementById("ajaxObj") : null;
	var reqLine='';
	var currform	=	eval("document."+formname);
	for(var i=0;i<currform.length;i++){
		reqLine+=currform[i].name+"="+escape(currform[i].value)+"&";
	}
	reqLine+="&frm="+formname+"&timestamp="+Math.random();
	objScript.contentWindow.document.forms['upd'].passed.value = reqLine;
	objScript.contentWindow.document.forms['upd'].act.value = action;
	objScript.contentWindow.document.forms['upd'].submit();
	return false;
}



function chgLoc(loc){
	var timerA;
	timerA=setTimeout(document.location.href=loc, 500);
}




function initAnchors()
{
	
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];

		if (anchor.getAttribute("rel") == "frametmb") {
			 anchor.onmouseover = function () {viewSlide(this.id); return false;};
			/* anchor.onmouseout = function () {runSlide(this.id);	return false;};	 */
		} /*else if (anchor.getAttribute("rel") == "bigtmb") {
			mainimages[main_images_index]=anchor; 
			main_images_index++;
			anchor.onmouseover = function () {swapBigImage(this); return false;};
			anchor.onclick	= function () {swapBigImage(this); return false;};
		}*/

		else if (anchor.getAttribute("rel") == "imagenav") {
		
			anchor.onclick = function () {moveStrip(this); return false;};
			 
		} else if (anchor.getAttribute("rel") == "risetip") {
		
			anchor.onmousemove =	function (event)	{	showReferenceTip(this,event);	}
			anchor.onmouseout =		function  ()		{	hideTip(this,'tip');	}
			anchor.onclick = function () {return false;};
			 
		} else if (anchor.getAttribute("rel") == "sorter"){
			anchor.onclick = function () {getTiresSorted(this); return false;}
		} else if (anchor.getAttribute("rel") == "page"){
			anchor.onclick = function () {gotoPage(this); return false;}
		}  
	}

	/*var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','tip');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.zIndex = '90';
	
	objBody.insertBefore(objOverlay, objBody.firstChild);*/
}

function chooseroom(currentID,qty){
	for (var i=1; i<=qty; i++ )
	{
		$('#thisisroom'+i).removeClass('thisroom');
		if (currentID == i)
		{
			$('#thisisroom'+i).addClass('thisroom');
		}
	}
}



function loadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}



function showReferenceTip(obj,event){
	
	var objContent=document.getElementById(obj.getAttribute('id')+'tip');
	if (!objContent) return;

	showtip('tip',objContent.innerHTML,obj,event)
	 
}




function showtip(tipid,objtxt,obj,event){
	var ObjTip = document.getElementById ? document.getElementById(tipid) : null;
	var ObjTipContent = document.getElementById ? document.getElementById(tipid+"content") : null;

	var coordinates = screenCoordinates(event);
	if (mdX==null || mdY==null)
	{
		mdX=coordinates[0];
		mdY=coordinates[1];
	}
	deltaX=Math.abs(coordinates[0]-mdX);
	deltaY=Math.abs(coordinates[1]-mdY);


	if ((deltaX>threshold || deltaY>threshold) || (deltaX==0 & deltaY==0))
	{
		mdX=coordinates[0];
		mdY=coordinates[1];
		var X =	mdX -365 ;
		var Y =	mdY -0;
		ObjTip.style.top =	Y+'px';
		ObjTip.style.left = X+'px';
		
		ObjTip.style.display='block';
		ObjTipContent.innerHTML=objtxt;
	}
	
}

function hidetip(){	
	str='hideLayer()';				
	timerB=setTimeout('eval(str)', 500);
}

function hideLayer(){
	var ObjTip = document.getElementById ? document.getElementById("tip") : null;
	var objScript = document.getElementById ? document.getElementById("tipcontainer") : null;
	ObjTip.style.visibility="hidden";objScript.src = "/tip.php";

}


function updatetip(name,value){
	var obj = document.getElementById ? document.getElementById(name) : null;
	obj.innerHTML = value;
	$('body').scrollTo( '#commentstart', 800, {queue:true} );
	/*$('body').scrollTop('commentstart')*/;
}


function movetip(obj){
	var ObjTip = document.getElementById ? document.getElementById("tip") : null;
	ObjTip.style.top=obj.clientY+document.body.scrollTop;
	ObjTip.style.left=obj.clientX+document.body.scrollLeft-250;
}

function getTiresSorted(obj){
	var sorttype=obj.getAttribute("title");

	document.forms.ad.pg.value=1;
	if (sorttype == document.forms.ad.sorttype.value)
	{
		if (document.forms.ad.sortorder.value==1)
		{
			document.forms.ad.sortorder.value=2;
		} else {
			document.forms.ad.sortorder.value=1;
		}
	} else {
		document.forms.ad.sorttype.value=sorttype;
		document.forms.ad.sortorder.value=1;
	}
	document.forms.ad.submit();
}

function updatePrice(obj,forone){
	var priceobj=document.getElementById ? document.getElementById("price") : null;
	priceobj.innerHTML=obj.value*forone;
}

function gotoPage(obj){
	document.forms.ad.pg.value=obj.getAttribute('title');
	document.forms.ad.submit();
}


function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}

function swap(id){
	$('#'+id).slideToggle(1000);
	return false;
}

function fixHolderHeight()  {
	if (correctContainerHeight == 0) return;
	if ($('#nomainimage').height() < 410)
	{
		$('#nomainimage').css('height', '410px');
	}
	
}

function maskSelects(){
	 $('#sradius, #swidth, #sprofile, #sseason').sSelect({ddMaxHeight: '300px'});
	 $('#sradius, #swidth, #sprofile, #sseason').change(function(){document.forms.ad.pg.value=1;$('#ad').submit();});

}


function harihalostop(){

}

$(document).ready(function(){
	
	initAnchors();
	maskSelects();
	/*startTopImagesAnimation();
	startSpecsSlideShow();*/
	/*$('#r_checkin').jdPicker();
	$('#r_checkout').jdPicker();   */
	/*fixHolderHeight();*/

	putaj();

});

