
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
	
}
function elem() {
        var els = new Array();
        for (var i=0;i<arguments.length;i++){
	        var el = arguments[i];
	        if (typeof el=='string')
		        el=document.getElementById(el);
	        if (arguments.length==1)
		        return el;
	        els.push(el);
        }
        return els;
  }

function Show(){
		for(var i=arguments.length-1;i>= 0;i--){elem(arguments[i]).style.display=""}
}

function Hide(){
		for(var i=arguments.length-1;i>= 0;i--){elem(arguments[i]).style.display="none"}
}


     var ProductPrice=[];
      
 function SetPrice(id,val){
  
        if(elem('your_price'+id)!=null){
             elem('your_price'+id).innerHTML = ProductPrice[val]["your_price"];
            if (ProductPrice[val]["your_price"]==''){Hide('your_price_txt'+id)}
            else {Show('your_price_txt'+id)}   
         };

        if(elem('you_save'+id)!=null){
            elem('you_save'+id).innerHTML = ProductPrice[val]["you_save"];
        }
    
        if(ProductPrice[val]["you_save"] == ''){     
									
						elem('reg_price_txt'+id).className = 'vcena';
            Hide('you_save_txt'+id);
         }
            else 
         {
             Show('you_save_txt'+id);
         }    
       

        if(elem('reg_price'+id)!=null){
             elem('reg_price'+id).innerHTML = ProductPrice[val]["reg_price"]
            if(ProductPrice[val]["reg_price"]==''){Hide('reg_price_txt'+id)}
            else {Show('reg_price_txt'+id)} 
            };

 }


// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function open_popup(theURL) { //v2.0
 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width=569,height=500');
}

function open_popup_wide(theURL) { //v2.0
 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width=670,height=500');
}

function PopupPic(sPicURL) {
     window.open( 'popup_image.asp?url=' + sPicURL, "",  "resizable=1,HEIGHT=200,WIDTH=200");
}

function hideDiv(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){//if they are 'see' divs 
if (document.getElementById) // DOM3 = IE5, NS6 
divs[i].style.visibility="hidden";// show/hide 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'hidden'; 
else // IE 4 
document.all.hideshow.divs[i].visibility = 'hidden'; 
} 
} 
} 

function showDiv(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.visibility="visible"; 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'visible'; 
else // IE 4 
document.all.hideshow.divs[i].visibility = 'visible'; 
} 
} 
} 


function changeclass(id, newClass) {

identity=document.getElementById(id);
identity.className=newClass;

}

function changestyle(id, ifWrite) {

identity=document.getElementById(id);
if (ifWrite ==1 )
identity.style.border='2px solid red';
else
identity.style.border='1px solid #30547d';
}

function changestyle_div(id, ifWrite) {

identity=document.getElementById(id);
if (ifWrite ==1 )
identity.style.border='2px solid red';
else
identity.style.border='none';
}

function isValidEmail(str) {
   return ( str.indexOf("@") > 0);
 
}

function ClickEmail(textbox_name)
 {
if (isValidEmail(textbox_name)) 
{
return(textbox_name)
}
else
{
return(' ')
}
}


function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
		
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}


function open_popup_full_screen(theURL) { //v2.0
var width=screen.availWidth;
var height=screen.availHeight;
 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width='+ width +',height='+ height+'');
}

function showDiv_display(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.display="block"; 

} 
} 
} 

function hideDiv_display(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.display="none"; 
} 
} 
} 

function div_obroki_change(id_obrok){
	

	if (id_obrok == 'bank_credit'){
	showDiv('div_obrok');
	hideDiv('div_kart');}

	
	if (id_obrok == 'credit_card'){
	showDiv('div_kart');
	hideDiv('div_obrok');}
	
	
	if(id_obrok == 'cash'){
	hideDiv('div_kart');
	hideDiv('div_obrok');}
	


}



function add_to_cart_new(pid, ptype, atc, site_domain) {
    
    var op_id = '';
    var ddl = 'select_menu' + pid;
    var _this;
    var inx = 0;
   
    if(elem(ddl)!=null){
 
        _this =elem(ddl);
        inx = _this.selectedIndex;
        op_id = _this.options[inx].value;
    }
     
    var sLink='/cart_add.asp?pid=' + pid + '&ptype='+ ptype +'&opid=' + op_id + '&atc='+ atc;
		
    
    document.location.href=site_domain+sLink;

}

function open_page_kredit(kredit, spec) {
    
    var st_anuitet = '';
    var nbr_obrok = document.getElementById('nbr_obrok');
    var _this;
    var inx = 0;
    if(nbr_obrok!=null){
        inx = nbr_obrok.selectedIndex;
        st_anuitet = nbr_obrok.options[inx].value;
    }
     
    var sLink='popup_kredit.asp?kredit=' + kredit + '&st_anuitet='+ st_anuitet+'&spec='+spec;
		
    open_popup(sLink);

}

function open_page_kredit_kartica(kredit, spec) {
    
    var st_anuitet = '';
    var nbr_obrok = document.getElementById('nbr_obrok_kartica');
    var _this;
    var inx = 0;
    if(nbr_obrok!=null){
        inx = nbr_obrok.selectedIndex;
        st_anuitet = nbr_obrok.options[inx].value;
    }
     
    var sLink='popup_kredit.asp?kredit=' + kredit + '&st_anuitet='+ st_anuitet+'&spec='+spec;
		
    open_popup(sLink);

}




function open_popup_center(theURL) { //v2.0

var w = 640, h = 480;
if (parseInt(navigator.appVersion)>3) {
 w = screen.width;
 h = screen.height;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 w = jScreenSize.width;
 h = jScreenSize.height;
}



var popW = 520, popH = 500;

var leftPos = (w-popW)/2, topPos = (h-popH)/2;


 MM_openBrWindow(theURL,'','scrollbars=yes,resizable=yes,width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos);
}



function hideDiv2(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){//if they are 'see' divs 
if (document.getElementById) // DOM3 = IE5, NS6 
divs[i].style.display="none";// show/hide 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'none'; 
else // IE 4 
document.all.hideshow.divs[i].display = 'none'; 
} 
} 
} 


function showDiv2(pass) { 
var divs = document.getElementsByTagName('div'); 
for(i=0;i<divs.length;i++){ 
if(divs[i].id.match(pass)){ 
if (document.getElementById) 
divs[i].style.display="block"; 
else 
if (document.layers) // Netscape 4 
document.layers[divs[i]].display = 'block'; 
else // IE 4 
document.all.hideshow.divs[i].display = 'block'; 
}
} 
}

function div_obroki_change(id_obrok){
 

 if (id_obrok == 'bank_credit'){
 showDiv('div_obrok');
 hideDiv('div_kart');}

 
 if (id_obrok == 'credit_card'){
 showDiv('div_kart');
 hideDiv('div_obrok');}
 
 
 if(id_obrok == 'cash'){
 hideDiv('div_kart');
 hideDiv('div_obrok');}
}

function div2_obroki_change(id_obrok){
 

 if (id_obrok == 'bank_credit'){
 showDiv2('div_obrok');
 hideDiv2('div_kart');}

 
 if (id_obrok == 'credit_card'){
 showDiv2('div_kart');
 hideDiv2('div_obrok');}
 
 
 if(id_obrok == 'cash'){
 hideDiv2('div_kart');
 hideDiv2('div_obrok');}
}


function getElem() {
        var els = new Array();
        for (var i=0;i<arguments.length;i++){
	        var el = arguments[i];
	        if (typeof el=='string')
		        el=document.getElementById(el);
	        if (arguments.length==1)
		        return el;
	        els.push(el);
        }
        return els;
  }
	
	
//###################AJAX MX email VALIDATE####################
function validateEmail(fld) {

    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
			
			
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\&\=\#\;\:\\\"\[\]]/ ;
		var error_mail = 0;
		
    if (tfld.value == "") {
   		
		error_mail = 1;
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
	
		error_mail = 1;
    } else if (tfld.match(illegalChars)) {
		error_mail = 1;	
    } else {
				error_mail = 0;
    }
    return error_mail;
}

//###################Email VALIDATE####################


// bookmark site code
function bookmarksite(title,url)
{
	if (window.sidebar) // firefox
		alert("Pritisnite ctrl + D za dodavanje u favorites.");
	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);
}


function show_video(page)
{
	  var jsCache = new Array();
    var AjaxObjects = new Array();

	    var url=page;

        var ajaxIndex = AjaxObjects.length;
        AjaxObjects[ajaxIndex] = new sack();
        AjaxObjects[ajaxIndex].requestFile = url;
        AjaxObjects[ajaxIndex].onCompletion = function(){ 

				document.getElementById('video_item').innerHTML = AjaxObjects[ajaxIndex].response;
				
				 };
        AjaxObjects[ajaxIndex].runAJAX();
}

// dropbox za email.si uporabnike
var dropboxleft=200;
var dropboxtop=300;
var dropspeed=50//10 //set speed of drop animation (larger=faster)

//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="always"

///Don't edit beyond here///////////

if (parseInt(displaymode)!=NaN)
var random_num=Math.floor(Math.random()*displaymode)
var ie=document.all
var dom=document.getElementById

function initbox(){
if (!dom&&!ie)
return
crossboxcover=(dom)?document.getElementById("dropinboxcover") : document.all.dropinboxcover
crossbox=(dom)?document.getElementById("dropinbox"): document.all.dropinbox
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossbox.height=crossbox.offsetHeight
crossboxcover.style.height=parseInt(crossbox.height)+"px"
crossbox.style.top=crossbox.height*(-1)+"px"
crossboxcover.style.left=dropboxleft+"px"
crossboxcover.style.top=dropboxtop+"px"
crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossbox.style.top)<0){
crossboxcover.style.top=scroll_top+dropboxtop+"px"
crossbox.style.top=parseInt(crossbox.style.top)+dropspeed+"px"
}
else{
clearInterval(dropstart)
crossbox.style.top=0
}
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closeCheckEmail(){
var crossboxcover = document.getElementById("dropinboxcover");
if (window.dropstart) clearInterval(dropstart)
crossboxcover.style.visibility="hidden"
}

function checkEmail(id){
//function checkEmail(id, ok, error, klicaj){
if(document.getElementById) { var vpisan_email = document.getElementById(id).value; }
else if ((document.all) && (!document.getElementById)) { var vpisan_email = document.all.id.value; } // ie4
else if (document.layers) { var vpisan_email = document.layers[id].value; } // ns4
else { var vpisan_email = document.all[id].value; }

var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;

var triman_email = vpisan_email.replace(/^\s+|\s+$/, '');

var error_email = document.getElementById(id);
var vseok = true;
var error = 'ok';

	//test email for illegal characters
	if(!emailFilter.test(triman_email)){
		vseok = false;
		return vseok;
	}
	else if(triman_email.match(illegalChars)){
		vseok = false;
		return vseok;
	}
	else if(vpisan_email.match(illegalChars)){
		vseok = false;
		return vseok;
	}
	
	if(vpisan_email == "" || vpisan_email == null){
		changestyle_div(id, 1);
		vseok = false;
		return vseok;
	}
	var email = vpisan_email.toLowerCase();

	if(!email.match("@")){
		changestyle_div(id, 1);
		vseok = false;
		return vseok;
	}

	AtPos = email.indexOf("@")
	StopPos = email.lastIndexOf(".") // dot, pika

	if (AtPos == -1 || StopPos == -1 || AtPos == 0 || StopPos-AtPos <= 2 || StopPos < AtPos || AtPos == email.length || StopPos == email.length || email.charAt(0) == '.') {
		changestyle_div(id, 1);
		vseok = false;
		return vseok;
	}
		
	var len = email.length;
		var pos = email.lastIndexOf ( '.', len - 1 ) + 1;
		if ((len - pos) > 4) {
			changestyle_div(id, 1);
			vseok = false;
			return vseok;
		}
		else if((len - pos) < 2) {
			changestyle_div(id, 1);
			vseok = false;
			return vseok;
		}

//var nedovoljenEmail = "@email.si";
var nedovoljenEmail = /@email.si/;
//nedovoljenEmail = email.search(nedovoljenEmail);
nedovoljenEmail = email.match(nedovoljenEmail);
var emailKoncnica = email.length - StopPos; // 3 more bit
	if (nedovoljenEmail != null && emailKoncnica != 3)
	{
		changestyle_div(id, 1);
		vseok = false;
		return vseok;
	}	

	if(nedovoljenEmail != null && emailKoncnica == 3)
	{
		//initbox();
		showDiv_display('form_error');
		changestyle_div(id, 1);
		document.getElementById('emailsi_text').style.display = "block";
		document.getElementById('viral_text').style.display = "none";		
		vseok = false;
		//vseok = 'error';
		return vseok;
	}
return vseok;
}
 

id = "newsletter_email";
function disableEnterKey(e)
{
     var key;     
     if(window.event){
          key = window.event.keyCode; //IE
     }
     else {
          key = e.which; //firefox
     }

	if(key == 13 && checkEmail(id) == false){
		return false;
    }
    else {
		return true;
    }
return (key != 13);
}

function checkemailform(){
var napaka=1
var ok = false

if(checkEmail('email') == false){
	napaka = 1;
}
else if(document.form_viral.surname.value == ''){
	napaka = 1;	
}
else if(document.form_viral.name.value == ''){
	napaka = 1;	
}
else if(document.form_viral.rules){
	if(document.form_viral.rules.checked == false){
	napaka = 1;
	}	
	else {
	napaka = 0;	
	}
}
else 
{
	napaka = 0;
}


	if(napaka == 0){
		ok = true;	
		document.form_viral.submit();
	}
	else {
		ok = false;
	}

return ok;
}

//adding to cart
function add_to_cart_dormeo(site_dom, pid, ptype, atc) {
    
    var op_id = '';
    var ddl = 'select_menu' + pid;
    var _this;
    var inx = 0;
   
    if(elem(ddl)!=null){
 
        _this = elem(ddl);
        inx = _this.selectedIndex;
        op_id = _this.options[inx].value;
    }
     
    var sLink=site_dom+'cart_add.asp?pid=' + pid + '&ptype='+ ptype +'&opid=' + op_id + '&atc='+ atc;
    
		
		window.open(sLink);
}


function fbs_click(u) {
if (u==''){
	u=location.href;
}
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}