// funkcija otvara nov prozor 
function check_delete(mess){
  return confirm(mess);
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

/* pokupio sam kao pomoc na ES-u */
/* valjda ce pomoci */
function reloadIfPopupClosed ()
{
   // _reloadIfPopupClosed ();
  //  alert('reload');
  //  var a=3+3;
  setTimeout ('_reloadIfPopupClosed ()',1000);
}
function _reloadIfPopupClosed ()
{
  //  alert('reload');
  //  try{
  //  windowReference=second;
    if (windowReference == 'undefined' ||
	typeof (windowReference.document) == 'unknown' || 
	windowReference.document == null ||
	windowReference==null)

    {
      window.location.reload();
      //alert('reload');
    }

}



function set_my_cookie(key,value){
  //  alert(value);
  setCookie(key,value,"Thu, 28-May-20 20:20:20 GMT","/");
}

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + value +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
// this function gets the cookie, if it exists
function get_cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}


function set_language(value){
  set_my_cookie('language',value);
  window.location.reload();
}
function set_currency(value){
  set_my_cookie('currency',value);
  window.location.reload();
}

function mail(to,subject){
  window.open("mail.php?to="+to+"&s="+subject,"","scrollbars=yes,toolbars=no,statusbar=no,locationbar=no"+
	      "width=775,height=490,top=0,left=0");
}

function details(id){
  windowReference = 
    window.open("details.php?id="+id,"second",
"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width=775,height=490");
  if (!windowReference.opener)
    windowReference.opener = self;

}

function gift_detail(id,alone){
  windowReference = 
    window.open("giftdetail.php?id="+id+"&alone="+alone,"second",
"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width=775,height=490");
		
  if (!windowReference.opener)
    windowReference.opener = self;

}
function gift_page(){
  windowReference = 
    window.open("gift.php?alone=1","second",
		"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width=775,height=490");

  if (!windowReference.opener)
    windowReference.opener = self;
}

function cart(){
  windowReference = 
    window.open("cart.php","second",
		"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width=775,height=490");
  if (!windowReference.opener)
    windowReference.opener = self;
}

function payment_instructions(){
	 windowReference = 
    window.open("instructions.php","",
"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width=775,height=490");
}

function prazanProzor(page,w,h){
window.open(page,"",
		"resizable=yes,scrollbars=yes,toolbar=no,status=yes,"+
"top=0,left=0,"+
"location=no,width="+w+",height="+h);

}
function navigate(url) {
    window.location.href = url;
}

function changeStyle(obj, new_style) {
  obj.className = new_style;
}
function toggle(id) {
  if ( document.getElementById(id).style.display=="none" )
    document.getElementById(id).style.display="";
  else
    document.getElementById(id).style.display="none";
}

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("aaaaaaaaaaaaaaaaaa")
e.select()
}
return returnval
}


