// display decision alert box

function decision(message, url){

	if(confirm(message)) location.href = url;

}



// open browser window

function openPopUp(url, windowName, w, h, scrollbar) {



           var winl = (screen.width - w) / 2;

           var wint = (screen.height - h) / 2;

           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;

		   win = window.open(url, windowName, winprops);

           if (parseInt(navigator.appVersion) >= 4) { 

              	win.window.focus(); 

           } 

}



function jumpMenu(target,object,restore){ 

  eval(target+".location='"+object.options[object.selectedIndex].value+"'");

  if (restore) object.selectedIndex=0;

}



function findObj(n, d) {

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function getImage(imageName)

{

		findObj('img').src = imageName;

}



function submitDoc(formName) { 

  var obj;

 

	if (obj=findObj(formName)!=null) 

	{

		findObj(formName).submit(); 

	}

	else 

	{

		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');

	}



}

/* ---------------------------- */

/* XMLHTTPRequest Enable 		*/

/* ---------------------------- */

function createObject() {

	var request_type;

	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer"){

	request_type = new ActiveXObject("Microsoft.XMLHTTP");

	}else{

		request_type = new XMLHttpRequest();

	}

		return request_type;

}



var http = createObject();



/* -------------------------- */

/* SEARCH					 */

/* -------------------------- */



function autosuggest() {

q = document.getElementById('search-q').value;

// Set te random number to add to URL request

nocache = Math.random();

http.open('get', 'searchautosuggest/lib/search.php?q='+encodeURIComponent(q)+'&nocache = '+nocache);

http.onreadystatechange = autosuggestReply;

http.send(null);

}

function autosuggestprice() {

q1 = document.getElementById('search-q1').value;

// Set te random number to add to URL request

nocache = Math.random();

http.open('get', 'searchautosuggest/lib/searchprice.php?q1='+encodeURIComponent(q1)+'&nocache = '+nocache);

http.onreadystatechange = autosuggestpriceReply;

http.send(null);

}

function autosuggestReply() {

if(http.readyState == 4){

	var response = http.responseText;

	e = document.getElementById('results');

	if(response!=""){

		e.innerHTML=response;

		e.style.display="block";

	} else {

		e.style.display="none";

	}

}

}

function autosuggestpriceReply() {

if(http.readyState == 4){

	var response = http.responseText;

	e = document.getElementById('results');

	if(response!=""){

		e.innerHTML=response;

		e.style.display="block";

	} else {

		e.style.display="none";

	}

}

}

function clear_textbox()

{

if (document.getElementById('search-q').value == "Търси по заглавия")

document.getElementById('search-q').value = "";

}

function clear_textbox1()

{

if (document.getElementById('search-q1').value == "Търси по цени")

document.getElementById('search-q1').value = "";

}

<!--
var popupWindow=null;
function popup(mypage,myname,w,h,pos,infocus){

if (pos == 'random')
{LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
else
{LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';popupWindow=window.open('',myname,settings);
if(infocus=='front'){popupWindow.focus();popupWindow.location=mypage;}
if(infocus=='back'){popupWindow.blur();popupWindow.location=mypage;popupWindow.blur();}

}
// -->

