﻿function CreateBookmarkLink(){
	title = document.title;
	url = window.location;
	if (window.sidebar) { 
	    window.sidebar.addPanel(title, url,"");
	} else if( window.external ) {
	    window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { 
	    return true; }
}

function ValidateCategory(x1,x2){
    x2.IsValid = !(x2.Value=='0' || x2.Value==null || x2.Value=='');
}

function ShowImage2(id,src){

    if(document.getElementById(id)!=null)
        document.getElementById(id).src=src;
}

function ShowPanel(id){
    var obj=document.getElementById(id);
    if(obj!=null)
        obj.style.display=(obj.style.display == 'none' ? '' : 'none');
}


function ShowWindow(url){
    window.open(url,null);    
}

function OpenWindow(url,params){
    window.open(url,'',params);
}

function CheckFeedBack(id1,id2){    
   document.getElementById(id1).disabled=(document.getElementById(id2).value=="" ? 'true' : '');
}

 function ShowBigPhoto(id){
    window.open('Gift-Photo'+obj[(curr_item+id)%(obj.length)]+'.aspx',null);    
}

function SetMainPhoto(id){
        
    document.getElementById('main_image').src='Gift-Medium-Photo'+obj[(curr_item+id)%(obj.length)]+'.aspx';
    var h=319;
    h/=prop[(curr_item+id)%(obj.length)];
    
    document.getElementById('main_image').style.height=h;
    document.getElementById('img_div1').style.height=h;
    document.getElementById('img_div1').style.top=-h;    
    document.getElementById('img_div3').style.height=h;   
  
}

function NextPhoto(n){
         
    curr_item+=n;
    
    if(obj.length==2){
        if(curr_item>1)
            curr_item=1;
        else if(curr_item<0)
            curr_item=0;
    }
    else{
        if(curr_item<0)
            curr_item+=obj.length;
        curr_item%=obj.length;
    }
    
    SetMainPhoto(0);

    
    //SetMainPhoto(0);
    
    if(obj.length<3) return;
    var o=document.getElementById('img_1');
    if(o!=null)
        o.src='Gift-Small-Photo'+obj[(curr_item-1+obj.length)%obj.length]+'.aspx';
    
    o=document.getElementById('img_2');
    if(o!=null)
        o.src='Gift-Small-Photo'+obj[(curr_item+1)%obj.length]+'.aspx';
}   

var curr_item=0;

var curr_id;
function ShowImagePanel(id){    
    if(curr_id != null && curr_id!='')
        document.getElementById(curr_id).style.display='none';
       
    curr_id=id;
    if(curr_id != null && curr_id!='')
        document.getElementById(curr_id).style.display='';
}

function ShowImage(id) {
    document.getElementById('or'+id).src="PhotoO"+id+".aspx";
}



function textBoxChangeTextFocus(id,text){
    var obj=document.getElementById(id);
    if(obj.value==text)
        obj.value='';
}

function textBoxChangeTextBlur(id,text){
    var obj=document.getElementById(id);
    if(obj.value=='')
        obj.value = text;
}


function _ShowPanel(id){
    var obj=document.getElementById(id);
    if(obj)
        obj.style.display='';
}

function _HidePanel(id){
    var obj=document.getElementById(id);
    if(obj)
        obj.style.display='none';
}
function SortClick(path,addParam,field,type){
	if(path.indexOf('?')>0) path+='&';
	else path+='?';
	
	window.location=path+'sort'+addParam+'='+field+'&stype'+addParam +'='+type;
}

function OpenCategoryPanel(id,id2){
    var obj=document.getElementById(id);
    var obj2=document.getElementById(id2);
    if(obj){
        obj.style.display=(obj.style.display=='none'?'':'none');
        obj2.src=(obj.style.display=='none'?'images/catalog_li_l1.gif':'images/catalog_li_l1_cur.gif');
    }      
}

var prev=0;
var currID=0;
function ShowItemImage(id,imageID,itemID){
    var link=document.getElementById('img_a_'+prev);
    link.className="";
    link=document.getElementById('img_a_'+id);
    link.className="cur";
    prev=id;
    
    document.getElementById('main_image').src='gifts/'+itemID+'/'+imageID+'-b.jpg';
    currID=imageID;
}
function OpenItemImage(def,itemID){
    if(currID==0)  currID=def;
    window.open('http://www.gifts.com.ua/gifts/'+itemID+'/'+currID+'-original.jpg');
}

function ShowHideItem(id1,id2){
    document.getElementById(id2).style.display=id1.checked?'':'none';
}

 function showPopup()
 {
  document.getElementById('popup_layer').style.display = 'block';
  document.getElementById('popup_blox_pre').style.display = 'block';  
  document.getElementById('popup_blox').style.display = 'block';
 }

 function hidePopup()
 {
  document.getElementById('popup_layer').style.display = 'none';
  document.getElementById('popup_blox_pre').style.display = 'none';  
  document.getElementById('popup_blox').style.display = 'none';
 }
