﻿// JavaScript Document

var tgs = new Array( 'div','td','tr');
var szs = new Array( 'xx-small','x-small','small', 'medium','large','x-large','xx-large' );
var startSz = 2;
var bIsSplash = false;
var giMinAuPlayerWidth = 320; //** Elka said that minimal width of audio player is 320
var giMinViPlayerWidth = 340;
var ChapterThumbBoxHeight = 130;
var bHasBanner = false;
if (typeof iChapPerPage == 'undefined')   var iChapPerPage;
if (typeof iCItemsPerPage == 'undefined') var iCItemsPerPage;
if (typeof bShowLoadLbL == 'undefined')   var bShowLoadLbL;
if (typeof bShowTrans == 'undefined')     var bShowTrans;
if (typeof iTSpeedOut == 'undefined')     var iTSpeedOut = 700; else iTSpeedOut=parseInt(iTSpeedOut);
if (typeof iTSpeedIn == 'undefined')      var iTSpeedIn = 400;  else iTSpeedIn=parseInt(iTSpeedIn);
if (typeof bLoadCommShown == 'undefined') var bLoadCommShown = false; else bLoadCommShown=YesNoToBool(bLoadCommShown);
if (typeof iCollapsedChapter=='undefined')var iCollapsedChapter;


//Detecting iPhone,iPod or iPad------------------------------------------------------------------------------------------------->VV->START

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
   var apple = 1;
   var winorient;
   orient();//Detect Orientation

  }else{
   var apple = 0;
  }
 //Detecting orientation of iPad,iPhone 
function orient(){
  switch(window.orientation){
     case 0: winorient = 1; //portrait
         break;
     case -90: winorient = 0; // landscape
         break;
		 
     case 90:  winorient = 0;
         break;		 		 
 	 case 180: winorient = 1; //portrait
         break;	 	

    }//end switch

}

//---------------------------------------------------------------------------------------------------------------------------->	END

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function doit(){
if (!window.print){
alert("You need NS4.x to use this print button!")
return
}
window.print()
}

function execLWinit(){
    return;
    
  if ( (!myLightWindow) && (lightwindowInit) ) {
        lightwindowInit();
        myLightWindow._addLightWindowMarkup(false);
    }
}

var _1stEtc = true;
function GetIList(url){
    var target='cont';
    var sLoadIcon = 'iconLoad'
    ShowLoading(sLoadIcon);
 
 /* change from 8.09.2009  ** /
    if (!myLightWindow){ // but it should not enter here if all has gone OK
      lightwindowInit();
    }
    if (!_1stEtc){
      myLightWindow.activate1();
      myLightWindow._displayLightWindow('block', 'visible');
      }

 /** end of the change **/
 
    var callback = {
            success : function(o) {
                var rst = o.responseText;
                updateScripts(rst, true);
                GE(target).innerHTML = rst;
                
                /**/
                HideLoading(sLoadIcon);
                if (myLightWindow){
                    myLightWindow._setupLinks();
		        } else  lightwindowInit();
		        
                if (GE('i1')) myLightWindow.activate(null, GE('i1')) /**/
		          
                // change from 8.09.09
                /*
                if (_1stEtc){
                     myLightWindow.initialize2();
                     _1stEtc = false;
                     if (GE('i1'))  myLightWindow.activate0(null, GE('i1'))
                            
                }else{
                     myLightWindow._setupLinks();
                     if (GE('i1'))  myLightWindow.activate2(null, GE('i1'))
                    }
                 */   
                
            },
            failure : function(o) {
                 GE(sLoadIcon).innerHTML = '';
                 alert('fail!')
            }
            
        };
  
  var conn = YAHOO.util.Connect.asyncRequest("GET", url, callback);

 
}
//<a id="i1" rel="Ga3657[3657]" z="" href="Artists/2285/Mediums/Medium_842008123043PM_212200573425PM_Phoenician2.jpg" class="lightwindow_marker hidden" title=""/>  
function addItems(_P_data){
    jQuery( "a", _P_data ).each(function( i ) {
				alert(jQuery)
					
				jQuery( "", "#cont" ).append([
					"<a href=\"",
					jQuery( "a", _P_data ).attr( "href" ),
					"\" class='lightwindow_marker hidden' rel=\"",
					jQuery( "a", _P_data ).attr( "rel" ),
					"\"></a>" ]);
	        
	});
}

function GE(id) {
    return document.getElementById(id)
}
function GS(id,style_property){
    return parseInt(YAHOO.util.Dom.getStyle(id, style_property) );
}
function myRemoveNode(obj){
  if (obj)   
      if (obj.removeNode)
                obj.removeNode(true);
       else { 
            var parent = obj.parentNode;
            parent.removeChild(obj);
        } 
}
function GoL(link){
    if (link.length > 0) document.location.href = link;
}

var gFirstBlog_link='';
function SetLIs(){
    
   var sCLink='', th_itemH, itemH ; 
   if (GE('imagepage')) sCLink=document.location;
   if (!iChapPerPage) iChapPerPage = 3;
   iChapPerPage = parseInt(iChapPerPage);
   
   
   var o, oP = GE('ul_slider');
   var oTH = YAHOO.util.Dom.getElementsByClassName("th_bg", null, YAHOO.util.Dom.get('slider'));  
   i=0 
   if(oTH.length > 0){
       //** set to the top menu link to the 1st item
        var p = oTH[i].getElementsByTagName('a');
        if (p.length >0){
            p = p[0];
            gFirstBlog_link = p.href;
        }
        
       //** set the width of the Left panel according to the number of items shown
       th_itemH = parseInt(oTH[i].offsetHeight);
       if (th_itemH == 0) th_itemH = ChapterThumbBoxHeight;
       
       th_itemH += parseInt(YAHOO.util.Dom.getStyle(oTH[i], 'marginBottom') ) -1; // margin-bottom
       YAHOO.util.Dom.setStyle('slider', 'height', (th_itemH * iChapPerPage)+'px'); 
       
    }
    //** set the height of the Chapter Items box of the active Chapter according to the Number selected in XML, if any 
    //** iCItemsPerPage shows how many atem to be visible
    if (!iCItemsPerPage) iCItemsPerPage='auto';
    if (iCItemsPerPage != 'auto'){
        var oILs = $('.itemsList_menu_wrapper', $('#slider'));
        for (cc = 0; cc<oILs.length; cc++){
           itemH=0;
            
           oP = oILs[cc];
           if (oP){
                oTH = $('a', oP);
                if (cc==5) {
                    var objid = '#'+oP.id;
                    obj = $('a', $(objid));
                    z = obj.length;  
                }
                 
                if (iCItemsPerPage < oTH.length){
                    for (i=iCItemsPerPage; i < oTH.length; i++){
                        $(oTH[i]).css('display', 'none');
                    }
                    
                    //--> add "More" row, with id
                    //--> onclick of MORE shows the other items
                    $(oTH[iCItemsPerPage-1]).after('<li><a href="javascript:ShowItems(\''+oP.id+'\', '+cc+');"  title="Click to see more items" class="pagename" id="more'+cc+'">MORE...</a></li>')

                }
            }
          } // end for
    }
    
    //** set the Categories link for the front page, asset page and guestbook page
    /*
    **** comented on 24.08.2010 - we dont use the 'pf' link now
    if (GE('frontpage') || GE('assetpage') || GE('guestbook')){
        if (gFirstBlog_link.length>0){
            var z = GE('pf');
            z = z.getElementsByTagName('a');
            if (z.length >0){
                z = z[0];
                z.href = gFirstBlog_link;
            }
        }
    }
    */
}

function ShowItems(objid, moreLnkID){
    $('#more'+moreLnkID).remove();
    var obj = $('a', $('#'+objid));
    $(obj).css('display', 'block');
}

function ShowLoading(target){
/***
    oMI = document.getElementById(target);
    
    if (oMI){
        var objILoading = document.createElement("div");
	    objILoading.setAttribute('id','imgLoading');
	    oMI.appendChild(objILoading);
	    
	    var oL2 = document.createElement("div");
	    oL2.className = 'iL2';
	    objILoading.appendChild(oL2);
	    
	    oL2.innerHTML = "<img src='CommonFiles/ajax-loader.gif' />"
	    
   }
 ***/
 }
function HideLoading(sLoadIcon){
    //**GE(sLoadIcon).innerHTML = ''
}


 var f = window.onload; 
if (typeof f == 'function'){
    window.onload = function() {
        f();
        OnloadFunc();
    }
}else window.onload = OnloadFunc;


function OnloadFunc(){
  SetHideAssets();
  
   //** if splash page
   if(bIsSplash) SetSplashThumbs();
   
   
  //** in image page
  if (GE('sta_vi')) PosStackVideoBtn(GE('peebles'));
  
  //*** for the Guestbook
  if (typeof DefCountry != 'undefined') {
        if ( !queryString('clid') ){
            setElementValue(document.form1.country, DefCountry);
            fillStates();
        }
   }
   
  $(function(){
        if (YesNoToBool(bShowTrans)) 
            if ( GE('assetpage') || GE('imagepage') ){
	            $("a.transition").click(function(event){
		            event.preventDefault();
		            linkLocation = this.href;
		            $("#content-con").fadeOut(iTSpeedOut, redirectPage);		
	            });
            		
	            function redirectPage() {
	                $("#content-con").css("visibility", "hidden");
	                $("#content-con").css("display", "block");
	                $("#collections").css("display", "none");
		            window.location = linkLocation;
	            }
	       }
   
   });
   
   //** custom opacity
   if (sBG)
      if (sBG.length>0 )
        if(typeof iWorkAreaTransparency != 'undefined')
          if (iWorkAreaTransparency>0 && iWorkAreaTransparency<100)
              $("#content").css("opacity", iWorkAreaTransparency/100);
   
   
}
if($)
    $(document).ready(function() {
        if (YesNoToBool(bShowTrans))
            if( GE('assetpage') || GE('imagepage') ){
                $("body").css("display", "none");

                $("body").fadeIn(iTSpeedIn);
            }
    });

function queryString( key )
{
    var re = new RegExp( "[?&]" + key + "=([^&$]*)", "i" );
    var offset = location.search.search( re );
    if ( offset == -1 ) return null;
    return RegExp.$1;
}

/// boza 
function high(o){
}
function low(o){
}

function getStyle(obj, classname){
    return parseInt(YAHOO.util.Dom.getStyle(obj, classname));
}



/***** top navigation menu ****/
var oSpec, special='';
function SetHideAssets(){
   
    if (typeof arAst == 'undefined' ) return;
    
   //** find which is the special asset by its id. the id comes from the xml in which the user has set it
   //** then this asset is put at the "special" div and extracted from the array with assets
    if (typeof featTxtPageID == 'undefined') featTxtPageID="";
    if (featTxtPageID.length>0 && arAst.length > 1){
        for(i=0; i< arAst.length; i++){
            if (arAst[i].id == parseInt(featTxtPageID)){
                special=arAst[i].text;
                oSpec = document.createElement('a');
                if (GE('special')) {
                     oSpec.innerHTML = special;
                     GE('special').appendChild(oSpec) ;
                     GE('special').style.visibility = "visible";
                }
                oSpec.href = arAst[i].onclick;
                if (! (arAst[i].target.indexOf('target="_self"')>-1 ||
                    arAst[i].target.indexOf('target=""')>-1 ||
                    arAst[i].target.indexOf('target')==-1) ) oSpec.setAttribute('target', '_blank');
                arAst[i] = null;
               
                break;
            }
        }
    }
    i=0;
   
   //** calculate the width that occupy the obligatory menus + special asset. The rest 
    //var arEls = ['hm','pf', 'cl', 'wc', 'special'], m_sum =0; -- 24.08.2010
    var arEls = ['hm', 'cl', 'wc', 'special'], m_sum =0;
    for(a=0; a< arEls.length; a++){
        if (GE(arEls[a])) {
            if (arEls[a]=='cl'){// add span tag
                cc = document.createElement('span')
                txt = GE(arEls[a]).firstChild.innerHTML;
                GE(arEls[a]).firstChild.innerHTML = '<span>'+txt+'</span>'
            }
            m_sum += GE(arEls[a]).offsetWidth;
            
            }
    }
    //*** set width of 'menuline' = the width of the menus visible
   
    var CoWidth = parseInt(getStyle('subheader', 'width'));
    var gW_MoreLbl =  GE('more')? parseInt(GE('more').offsetWidth) : 0;
    //** hide 'more' button
    GE('more').style.display = 'none';
 
    var iW_Limit = CoWidth - m_sum - gW_MoreLbl;
    var i, t_W ;
   
    
     for ( ; i<arAst.length-1; i++){ // we don't need the last element of this array, because it is ficticious
        if (!arAst[i]) continue;
        
        var x, y, z,p;
        x = document.createElement('li');
        
        y = document.createElement('a');
        y.setAttribute('href', arAst[i].onclick)
        if (! (arAst[i].target.indexOf('target="_self"')>-1 ||
                arAst[i].target.indexOf('target=""')>-1 ||
                arAst[i].target.indexOf('target')==-1) ) y.setAttribute('target', '_blank');
        y.className = 'transition';
        if (typeof iActAsset != 'undefined') if (iActAsset == arAst[i].id) y.className = 'active transition';
                    
        z = document.createElement('span');
        z.className = 'menuspans';
        z.innerHTML = arAst[i].text;
        
        
        y.appendChild(z);
        x.appendChild(y);
        GE('menu').appendChild(x);
    
        t_W = x.offsetWidth;
       
        if (t_W <= iW_Limit){ // add it
            //** 1. add onclick event
         //   if (arAst[i].onclick) YAHOO.util.Event.addListener('tm'+i, 'click', G_Asset, {fn: arAst[i].onclick.fn}, true);
            //** 2. make visible
            //** 3.remove item from arAst
            arAst[i] = null;
            //** 4. update iW_Limit variable;
            iW_Limit -= t_W;
            //** change the width of 'menuline' adding the width of this element
            m_sum += t_W;

       }else{
            //** 1. remove element from document
            myRemoveNode(x);
            //** 2. add 'more' label
            GE('menu').appendChild(GE('more'));
            //** 2A. show 'more' button
            GE('more').style.display = 'block';
            GE('more').style.visibility = 'visible';
            //** 3. stop cicle;
            GoMoreMenu();
            //** change the width of 'menuline' adding the width of the MORE menu
           // m_sum += gW_MoreLbl;
           // GE('menu').style.width = m_sum + 'px';
            break;
       }

    }

}

 function G_Asset(){
    this.fn();
 }
 var anylinkmenu0;
 function GoMoreMenu(){
    
    anylinkmenu0={divclass:'anylinkmenu', inlinestyle:'', linktarget:''} //Second menu variable. Same precaution.
    var z= new Array(), p=0;
    
    for (a=0; a<arAst.length-1; a++) // we don't need the last element of this array, because it is ficticious
        if (arAst[a]) {
         
            z[p++] = [arAst[a].text, arAst[a].onclick, (arAst[a].onclick.indexOf('http://')==0? '_blank':''), 'transition']
    
        }

    
    anylinkmenu0.items = z;
   
    anylinkmenu.trueinit("menuanchorclass");
}






function wlog( content,flAddNew){
    var  id="logger";
    var dv = GE(id);
    
    if (!dv){
        dv = document.createElement('div');
        dv.setAttribute('id',id);
	    document.body.appendChild(dv);
    }
     
    if (flAddNew)
        dv.innerHTML =content+ "<br>"
    else
        dv.innerHTML =  dv.innerHTML +content+"<br>"
   
        
}

function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function collapseList(objID){
    //var el = document.getElementById(objID);
    var el = $('#'+objID);
    //alert($('#'+objID).css("display")+'\n'+$('#'+objID, 'ILSet').css("display"))
	if ( el.css("display") != "block" ) {
		//el.style.display = 'block';
		//document.getElementById(iCollapsedChapter).style.display='none';
		el.css('display', 'block')
		if (iCollapsedChapter!='') $('#'+iCollapsedChapter).css("display","none");
		iCollapsedChapter = objID;
	}
	else {
		//el.style.display = 'none';
		el.css("display", "none")
		iCollapsedChapter = '';
    }
}
var arLName = ['items_list', 'cats_list'], arLClass = ['vis', 'hid'];
function changeMenu(iobj, iclass) {
    GE(arLName[iobj]).className = 'list_'+ arLClass[iclass];
    //** set the other list to do the opposite
    GE(arLName[1-iobj]).className = 'list_'+ arLClass[1-iclass];
   // alert(arLName[iobj]+': '+GE(arLName[iobj]).className+'\n'+arLName[1-iobj]+': '+GE(arLName[1-iobj]).className)

}
function changeMenuPos(X) {
    GE('content').className = 'case_'+X

}


var arIFields = ['topcontainer', 'options', 't-name', 't-description', 'm1', 'price_cont', 'pricing', 'tc2', 'comBo', 'control']  //, 'comNu'

function fadein(){ $("body").fadeIn(iTSpeedIn);}

function GetItemPage(link, arID ){
    // check if cliked the  active item , then return;
    // to be implemented....

    GoLoad();
    
    //** added 7.07.2010-stef
    //** check if the item clicked is from the current loaded chapter or not
    //** if not - reload page, else -use ajax
    if (arID[1]!= sGalleryID){ GoL(link);return}
    
    //** if   bLoadCommShown is true, then I care what is the value of the arImgComs
    //** if false -> the pages will always load with ajax; Default is No(false)
    t_flag = (bLoadCommShown? parseInt(arImgComs[matchConsecNumber(arID[0])]) : 1);
        
    if (t_flag == 1) {
        if (GE('comBo')) GE('comBo').innerHTML='';
        
       // var callback = fn_callback(link, arID);
          var callback = fn_callback;
        //var conn = YAHOO.util.Connect.asyncRequest("GET", link+'&ajx=1', callback);
        z=$.ajax({
            data: 'ajx=1',
            type: "GET",
            url: link,
            timeout: 20000,
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            dataType: 'html',
            success: callback, 
            params: [arID]
        });
        
    }
    else
        document.location.href = link;
}


function fn_callback(data, status, objXmlHttpR){

  /*  var callback = {
        success : function(o) {
       alert('go')           
   */         //** hide loader
           setTimeout('HideLoad()',100);
            
           arID = this.params[0];
           func = function(){
			
                //var rst = o.responseText;
                var rst = data;
                
                var otemp = document.createElement("div");
                otemp.innerHTML = rst;
				
                for (i=0; i< arIFields.length; i++){
                    SetDataFromTo(otemp, arIFields[i]);
                  
               }
               
               //** check for stack or video link button and position it
               SetStack();
               
               setSelClass(arID);
                 
                //makeScrollable("div.sc_menu_wrapper_h", "div.sc_menu_h", 'horizontal');
                //changeMenu(0, 0);
               
                if(GE('t-description').innerHTML.length>0){ 
                //*** show gallery strip at the botton and expanded menu
                    if (!bHasBanner){
                        changeMenuPos(1);
                        GE('rightcolumn').className = '';
                    }
                }
                else {
                //*** IMAGE ONLY mode
                   if (!bHasBanner){ 
                        changeMenuPos(2);
	                    GE('rightcolumn').className = 'rc_1';
	               }    
	                    
                }
    
                $("#content-con").fadeIn(iTSpeedIn);
                  
              } // end func
              

           if (YesNoToBool(bShowTrans))
                $("#content-con").fadeOut(iTSpeedOut,func); //** end fadeOut
           else
                func();
  /*    
        },
        failure : function(o) {

        }
    }
    return callback.success;
    */
}

function SetDataFromTo(oSrc, tgt_F){

        if (oSrc && YAHOO.util.Dom.get(tgt_F)){
            var arO, i;
            arO = oSrc.getElementsByTagName('div');
            
           
           for (i=0; i< arO.length; i++){
               // if(tgt_F=='comBo') alert(arO[i].getAttribute('id')+'\n\n'+arO[i].innerHTML)            
                
                if (arO[i].getAttribute('id') == tgt_F) 
                    {
                         var p = arO[i].innerHTML;
                       //  if(tgt_F=='comBo') updateScripts(p, true); // added 7.12.2009
                       //  YAHOO.util.Dom.get(tgt_F).innerHTML = p;

                         if(tgt_F=='comBo' || tgt_F=='comNu') {
                         
                            //*** when DISQUS commentig system
                            // window.disqus_no_style = true;
                            //updateScripts(p, true); // added 7.12.2009
                            //** getComBoJSContent(p);
                          
                            YAHOO.util.Dom.get(tgt_F).innerHTML = p;
                            
                         }
                         else
                            YAHOO.util.Dom.get(tgt_F).innerHTML = p;
                         
                         return;
                     }
                
           }

        }
          
    }

function OpenCo(src) {
    
   // var callback = fn_cb_OC(src);
   // var conn = YAHOO.util.Connect.asyncRequest("POST", src, callback);
   GE('IFrComm').src = src;
//   GE('comBo').innerHTML = 

  // setTimeout('ZZZ()', 2000)
}


function SetStack(){
   if (GE('sta_vi')){
        //otemp = GE(arIFields[0]).getElementsByTagName('img')
        var oo = GE('tc2')? GE('tc2') : GE('topcontainer')
        otemp = oo.getElementsByTagName('img');
        if (otemp.length>0){
            otemp=otemp[0];
            YAHOO.util.Event.addListener('peebles', 'load', function(){ PosStackVideoBtn(otemp)} );
        }
    }
}

var gv_ImgW;
function PosStackVideoBtn(mm){
   var oSta = GE('sta_vi');
  /*
   var z = GS(arIFields[0], 'height');
   if (!z) z= GE(arIFields[0]).offsetHeight;
   calc_pos = (z - mm.height )/2;
   if (calc_pos<0) calc_pos=0;
   YAHOO.util.Dom.setStyle(oSta, 'bottom', calc_pos+'px');
  */
  // z = GS(arIFields[0], 'width');
  // if (!z) z= GE(arIFields[0]).offsetWidth;
   var boxID = 'tc';
   if(GE('tc2')) boxID = 'tc2';
   
   z = GS(boxID, 'width')
   if (!z) z= GE(boxID).offsetWidth;
 // alert(mm.src+'\n'+z+", mm.width="+mm.width)
   calc_pos = (z - mm.width )/2
   if (calc_pos<0) calc_pos=0;
   YAHOO.util.Dom.setStyle(oSta, 'right', calc_pos+'px');
   
   gv_ImgW = mm.width;
}

  function ShowAu(iSource,vol){
     GE('sta_vi').style.display='none';
     
     var obj_h = document.createElement('div');
     obj_h.className = 'audio_layer_ho';
 if(apple==0){ //Works on all browsers that support flash ------------------------------------------------------------------------------->VV
     var obj = document.createElement('div');
     obj.className = 'audio_layer';
     if (gv_ImgW>0) {
        if (gv_ImgW<giMinAuPlayerWidth) gv_ImgW = giMinAuPlayerWidth;
        YAHOO.util.Dom.setStyle(obj, 'width',  gv_ImgW+'px');
      }
     
      
     
     var iH, iW, code;
     iH = 30;
     iW = gv_ImgW;
     code = AC_FL_RunContent(
		"src", "MP3Player",
		"width", "100%",
		"height", iH,
		"id", "MP3Player",
		"quality", "high",
		"bgcolor", "#869ca7",
		"wmode", "transparent",
		"name", "MP3Player",
		"flashvars",'source='+encodeURIComponent(iSource)+'&bgcolor=0x000000&closeFunctName=CloseStackView&paramForCloseFinction=oBoxSV&fl=1&volume='+vol,
		"allowScriptAccess","sameDomain",
		"type", "application/x-shockwave-flash",
		"pluginspage", "http://www.adobe.com/go/getflashplayer",
		"scaleContent", "false",
		"scale", "noscale",
		"salign", "lt",
		"allowFullScreen", "true"
        );   
	  
	  obj.innerHTML = code;  
	  
	  
	   }  
	else if(apple==1) {//if apple products------------------------------------------------------------------------------------------VV->START audio for iPad,iPhone etc
	
	   var obj = document.createElement('audio');
	   obj.setAttribute('src', iSource);
	 obj.setAttribute('autoplay', 'autoplay');
	  obj.setAttribute('controls', 'controls');
	obj.className = 'audio_layer';
	}
	  //---------------------------------------------------------------------------------------------------------------------------VV->END audio for iPad,iPhone etc
	   
	  obj_h.appendChild(obj) 
	      
      GE('sta_vi').parentNode.appendChild(obj_h);
	 
 }


function setSelClass(arID){
   /*
   var iNVa = iID.toString().replace('d', actImgNum);
   iNVa = eval(iNVa);
   if(GE('all_img')) {
       iCount = parseInt(GE('all_img').innerHTML);
       if (iNVa<1) iNVa = iCount;
       else if (iNVa>iCount) iNVa = 1;
   }
    */
    
    var iNVa = matchConsecNumber(arID[0]);

   GE('iL'+arID[1]+'_'+actImgNum).className = GE('iL'+arID[1]+'_'+actImgNum).className.replace('Sel','');   //'pagename';
   GE('iL'+arID[1]+'_'+iNVa).className = GE('iL'+arID[1]+'_'+iNVa).className.replace('pagename', 'pagenameSel');    //'pagenameSel';
   actImgNum = iNVa;
   
}
function matchConsecNumber(iID){
   var iNVa = iID.toString().replace('d', actImgNum);
   iNVa = eval(iNVa);
   if(GE('all_img')) {
       iCount = parseInt(GE('all_img').innerHTML);
       if (iNVa<1) iNVa = iCount;
       else if (iNVa>iCount) iNVa = 1;
   }
   
   return iNVa;
}

function updateScripts( html, loadScripts){

        if(!loadScripts) return;
        
        var _parseScripts = function(){
            var docHead = document.getElementsByTagName("head")[0];
         
            var re = /(?:<style.*(?:src=[\"\'](.*)[\"\']).*>.*<\/style>)|(?:<style.*>([\S\s]*?)<\/style>)/ig; // assumes HTML well formed and then loop through it.
            var match;
            while(match = re.exec(html)){
                 var s0 = document.createElement("style");
                 if (match[1])
                    s0.src = match[1];
                 else if (match[2]){
                    s0.setAttribute("type", "text/css");
                    if(s0.styleSheet){// IE
                        s0.styleSheet.cssText = match[2];
                    } else {// w3c
                        var cssText = document.createTextNode(match[2]);
                        s0.appendChild(cssText);
                    }
                    }
                 else
                      continue;
                 docHead.appendChild(s0);
            }   
             
             
            var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img; 
            var sRe = /(?:<script.*?>)/i;
            var srcRe = /\ssrc=([\'\"])(.*?)\1/i;   
            
            var match, sTagMatch, srcMatch;
         
            while(match = re.exec(html)){
                sTagMatch = match[0].match(sRe);
                if (sTagMatch) {
                    srcMatch = sTagMatch[0].match(srcRe);
                    if(srcMatch && srcMatch[2]){
                       var s = document.createElement("script");
                       s.src = srcMatch[2];
                       docHead.appendChild(s);
                    }else if(match[1] && match[1].length > 0){
                               var s = document.createElement("script");
                               s.type = 'text/javascript';
                               if(navigator.userAgent.indexOf("Safari")!=-1){//code being in a variable is important - this is Safari hack ;)
                                    window.my_code = match[1]; 
                                    s.innerHTML = 'eval(window.my_code)';
                               }
                               s.text = match[1];   
                              docHead.appendChild(s);
                        }                     
                }
            }
            
        }
        
        // set timeout to give DOM opportunity to catch up
        setTimeout(_parseScripts, 20);

}

function addScriptToHeaD(sScrSrc){
    var docHead = document.getElementsByTagName("head")[0];
    var s = document.createElement("script");
    s.type = 'text/javascript';
    s.src = sScrSrc;
    docHead.appendChild(s);
}


/*** panel  **/
var oBox;
if (typeof YAHOO != 'undefined'){
    YAHOO.namespace("example.container");
    YAHOO.example.container.oname = '';
}

function initZ(SID, W, H) {

    actPriceNum = 1;

    if (!GE('pco')){
        var dv = document.createElement('div');
        dv.setAttribute('id', 'pco');
        dv.setAttribute('height', H+'px');
        document.body.appendChild(dv)
    }else
        var dv = GE('pco');
        
    dv.innerHTML = GE('price_cont').innerHTML;
   
 //   var H = dv.offsetHeight;
   
    //YAHOO.namespace("example.container");
   // YAHOO.example.container.oname = '';

    oname='ft';
  //  oBox = eval('YAHOO.example.container.'+oname);
   // YAHOO.example.container.oname = oname;

    if (!oBox) {
        oBox = new YAHOO.widget.Panel(oname,  
                                            { width: W+'px',
                                              height: H+'px',
                                              fixedcenter: false, 
                                              close: true, 
                                              draggable: true, 
                                              zindex:9999,
                                              visible: false,
                                              modal:true
                                            } 
                                        );
    oBox.beforeShowEvent.subscribe(	function(){this.element.style.display='block'   });
    oBox.renderEvent.subscribe(	function(){this.header.style.display='none'    });
    // eval('YAHOO.example.container.'+oname+'=oBox');

    init_more( oBox, SID, W, H);
   
    //NO:: GE('ft_c').style.height = parseInt(oBox.element.offsetHeight)+'px';
    
  }else {
    oBox['cfg'].setProperty('height', H+'px')
  
  }
  

    //*** Show the Panel
    oBox.show();
    oBox.beforeHideEvent.subscribe(	function(){this.element.style.display='none'   });
    
}
  
function init_more(oContainer, iSource, iW, iH){
    var dv = GE('pco');

    oContainer.setBody(dv);
    
    //oContainer.renderEvent.subscribe(function(){this.header.style.display='none'});
    oContainer.render(document.body);
    oContainer.center();
}  

/** panel 2 **/

var oBoxSV;
function initSV(SID, args, type) {

    W = args[0];
    H = args[1];
    if (args[2]) V = args[2];
    
    oname='sv';
    oBoxSV = eval('YAHOO.example.container.'+oname);
    YAHOO.example.container.oname = oname;

    if (!oBoxSV) {
        oBoxSV = new YAHOO.widget.Panel(oname,  
                                            { width: W+'px',
                                              height: H+'px',
                                              fixedcenter: false, 
                                              close: false, 
                                              draggable: true, 
                                              zindex:9999,
                                              visible: false,
                                              modal: true
                                            } 
                                        );
     //if (type!=1) oBoxSV.renderEvent.subscribe(	function(){this.header.style.display='none'    });

     eval('YAHOO.example.container.'+oname+'=oBoxSV');
  }
    
     if (type!=1) oBoxSV.renderEvent.subscribe(	function(){this.header.style.display='none'    });
     else oBoxSV.renderEvent.subscribe(	function(){this.header.style.display='block'    });


    initSV_more( oBoxSV, SID, args, type);

    //*** Show the Panel
    oBoxSV.show();
    
    
    
    if (type==2&&apple==0){// hide click to close layer in iPad-------------------------vv
		
        var x, y;
        x = GE(oname);
        if (x){
            if (!GE('vi_close_layer')){
                y = document.createElement('div')
                y.setAttribute('id', 'vi_close_layer');
                y.innerHTML = "Click to Close";
                x.appendChild(y);
			 
                YAHOO.util.Event.addListener('vi_close_layer', 'click', function(){ CloseStackView_V(oBoxSV)});
                YAHOO.util.Event.addListener(oname, 'mouseout', function(){ GE('vi_close_layer').style.visibility = 'hidden'; });
				
				
             }
            YAHOO.util.Event.addListener(oname, 'mouseover', function(){ GE('vi_close_layer').style.visibility = 'visible'; });
            
        }
    } 
    
}

 function initSV_more(oContainer, iSource, args, iType){

    iW = args[0];
    iH = args[1];
    iBuffT = (args[2]? args[2] : 0);
    
    
    switch (iType){
    
    case 1: //** stack viewer
       
	   if(apple==0){//--------------------------------------------------------------------------------------------------------------------->vv
		  
       iH = iH+250;
       code = AC_FL_RunContent(
	        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0',
	        'width', iW,
	        'height', iH,
	        'src', 'SlideShow',
	        'quality', 'autohigh',
	        'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
	        'align', 'top',
	        'play', 'false',
	        'loop', 'true',
	        'scale', 'noscale',
	        'wmode', 'transparent',
	        'bgcolor', '',
	        'devicefont', 'false',
	        'id', 'SlideShow',
	        'name', 'SlideShow',
	        'menu', 'false',
	        'allowFullScreen', 'false',
	        'allowScriptAccess','sameDomain',
	        'movie', 'SlideShow', 
'flashvars','folderId='+iSource+'&isSlideshow=0&sKey='+sSKey+'&customerId='+sArtistID+'&cKey='+sSKey+'&isFA=1&fileFrom='+sAppurl+'fl5s.asp&path='+sAppurl+'fl5.asp&isPreview=0&toShowCloseButton=0&closeFunctName=CloseStackView&paramForCloseFinction=oBoxSV',
	        'salign', 'lt'
	        ); 
			   
		
	   }
	   else if(apple==1){ //------------------------------------------------------------------------------------------------------>VV->START Slide show for iPad,iPhone etc
		  scroll(0,0);
		   slideShowOn=1;
		  box=1;
           SSpopup();	
	
		  
		  code= document.createElement("div");	   
		   code.setAttribute('id', "SlideShowSV");
		   code.setAttribute('class', "SlideShowSV");	
	      
		   iH = iH+250;
		   
		   
		 if (window.XMLHttpRequest)
                 {// code for IE7+, Firefox, Chrome, Opera, Safari
                     xmlhttp=new XMLHttpRequest();
                      }
             else
                  {// code for IE6, IE5
                          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                      } 
					
					xmlhttp.open("GET","fl5.asp?customerId="+sArtistID+"&sKey="+sSKey+"&folderId="+iSource+"&isSlideshow=1",true);
                   
				   xmlhttp.send();
                   xmlhttp.onreadystatechange=function()
                   { 
                        if (xmlhttp.readyState==4 && xmlhttp.status==200)
                           {
					 		var xx,Aurl,description;
						 	var yy ="";
							var imgs="";
							
							var myImg = new Array();
                               xx =xmlhttp.responseXML.documentElement.getElementsByTagName("image");
							   description = xmlhttp.responseXML.documentElement.getElementsByTagName("iDescription");
						 	    Aurl = xmlhttp.responseXML.documentElement.getElementsByTagName("url_base")[0].firstChild.nodeValue;
								
							  var srcvar ="'"+Aurl+""+xx[0].attributes[3].nodeValue+"'";
								for(var i=0;i<xx.length;i++){
								    var option ="";
									price = new Array();
									Wi = new Array();
									Heig = new Array();
									weig = new Array();
									OI = new Array();
									var oo = xx[i].getElementsByTagName("PriceOption");	
									var oi= xx[i].getElementsByTagName("poSaleInfo");	
									if(oo.length>0){
								           for(var j=0; j<oo.length; j++){
											   price[j] = oo[j].attributes[2].nodeValue;
											   Wi[j] = oo[j].attributes[3].nodeValue;
											   Heig[j] =  oo[j].attributes[4].nodeValue;
											   weig[j] = oo[j].attributes[5].nodeValue;
											   if(oi.length>0){
											  OI[j] = oi[j].firstChild.nodeValue;
											   }
											   else{
												 OI[j] = "No Information";  
											   }
									          option = option + "<option value='"+price[j]+", "+Wi[j]+", "+Heig[j]+", "+weig[j]+", "+OI[j]+"'>"+oo[j].attributes[1].nodeValue+"</option>";
							   
									         }
									
							            var info = "<table><tr><td>Select Options:</td><td colspan='3'><select id='selectPrice' onchange='dispPriceinfo(this.value)'>"+option+"</select></td></tr><tr><td>Price </td><td colspan='3'><span class='tdborder' id='newSS0'>"+price[0]+"</span> USD</td></tr><tr><td>Dimensions </td><td>Width <span class='tdborder' id='newSS1'>"+Wi[0]+"</span></td><td>Height <span class='tdborder' id='newSS2'>"+Heig[0]+"</span></td><td>Weight <span class='tdborder' id='newSS3'>"+weig[0]+"</span></td></tr><tr><td>Other Info</td><td colspan='3'  class='tdborderOI' id='newSS4'>"+OI[0]+"</td></tr><tr><td></td><td colspan='3'><a href='#'>Add to Cart</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='#'>Checkout</a></td></tr></table>";
							  
								}
								    else{
										  var info = "";
										 
									}
							  	
							  
									
							
								if(document.images)
								{
									preload_image_object = new Image();
									image_url = new Array();
									image_url[i]=Aurl+""+xx[i].attributes[3].nodeValue;
									preload_image_object.src=image_url[i];
									yy=yy+"<li><img src='"+preload_image_object.src+"'/><span>"+description[i].firstChild.nodeValue+"</span><div class='priceOP'>"+info+"</div><div>"+xx[i].attributes[1].nodeValue+"</div><div>"+xx[i].attributes[2].nodeValue+" / "+xx.length+"</div></li>";
									
								}
								
								}
							
								
								
							var slideShow = "<ul id='slideS'>"+yy+"</ul>";
							  document.getElementById("SlideShowSV").innerHTML= slideShow;
					
							 galview(iW,iH, xx.length);
							
                             }
                       }
                     
 	} //--------------------------------------------------------------------------------------------------------------------------------------->VV->END Slide show for iPad,iPhone etc
 	
        //*** get the background color of the #contet element and set the same  background for the close button. 
        //*** If the bgr is 'transparent' - set the background of the <body>
	    var cclose_bgr = $('#content').css('background-color');
	    if (cclose_bgr == 'transparent') cclose_bgr = $('body').css('background-color');
	    
	    oContainer.setHeader('<div class="cclose_2" onclick="CloseStackView(oBoxSV)" style="background-color:'+ cclose_bgr+ '">CLOSE&nbsp;&nbsp;&nbsp;<span class="cc2_i">X</span>&nbsp;&nbsp;</div>');
	    iH = iH + 30;// header height;   
		
	    break;
	    
    case 2:  //** video
	
	   if(apple==0){ //works in all browsers that support flash
       if (iW <giMinViPlayerWidth) iW = giMinViPlayerWidth;
       code = AC_FL_RunContent(
			"src", "Vplayer",
			"width", iW,
			"height", iH,
			"align", "middle",
			"id", "Vplayer",
			"quality", "high",
			"bgcolor", "#869ca7",
			"wmode", "transparent",
			"name", "Vplayer",
			"flashvars",'source='+encodeURIComponent(iSource)+'&bgcolor=0x000000&closeFunctName=CloseStackView_V&paramForCloseFinction=oBoxSV&bufferLen='+iBuffT,
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer",
			"scaleContent", "false",
			"scale", "noscale",
			"allowFullScreen", "true",
			'salign', 'lt'
	        );
			iH=iH+30;
	   }
	   else if(apple==1){//works in apple products--------------------------------------------------------------------------------------->VV->START Video player for iPad,iPhone etc
	   scroll(0,0);
	   code="<div onclick='CloseStackView(oBoxSV)'>CLOSE&nbsp;&nbsp;&nbsp;<span class='cc2_i'>X</span>&nbsp;&nbsp;</div>";
	   var videoobj="<video src='"+iSource+"' autoplay='autoplay' controls='controls' width="+iW+" height="+iH+"></video>";
       code = code+videoobj;
	   } 
	  
	   //--------------------------------------------------------------------------------------------------------------------------------->VV->END Video player for iPad,iPhone etc
	    break;
	   
	case 3:  //** audio
	
	}


	 oContainer.setBody(code);
//       oContainer.renderEvent.subscribe(function(){this.header.style.display='none'});
       oContainer.render(document.body);
       
     //**CenterIt(oContainer, iW, iH);
     oBoxSV.configHeight('sv',[iH+'px'])
      oBoxSV.configWidth('sv',[iW+'px'])


       oContainer.center();
       
    }
    

//-------------------------------------------------------------------------------------------------------------------------------->VV 
/* Slide show pricing information when options are changed*/   
function dispPriceinfo(val){
	
 var newresults = val.split(",");
  for(var i=0;i<5;i++){
  GE('newSS'+i).innerHTML = newresults[i];
}
             }
						 
/*Slide show */
function galview(imageWidth,imgHeight,nofImg){
					
$('#slideS').PikaChoose({auto_play:true, image_height:imgHeight-250, image_width:imageWidth, number_images:nofImg});
	
	
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------->VV
 function CenterIt(obj, W, H){

    mTop = -H/2 +  GS('header', 'height') + GS('IContainer', 'paddingTop') - (GS('holder2', 'height') - H)/2 + (GS('fpimg', 'height')-H)/2
    mLeft = -W/2 + GS('IContainer', 'paddingLeft') - (GS('holder2', 'width') - W)/2 + (GS('fpimg', 'width')-W)/2
    GE('ft_c').style.marginTop = mTop+'px';
    GE('ft_c').style.marginLeft = mLeft+'px';
 }
 
 function CloseStackView(o){
    var obj = eval(o);
    obj.setBody('');
    obj.hide();
	if(apple==1){
		box=0;
		slideShowOn=0;
	}
}

 function CloseStackView_V(o){
	 
    GE('vi_close_layer').style.visibility = 'hidden';
    
    var obj = eval(o);
    YAHOO.util.Event.removeListener(obj.id, 'mouseover');
    obj.setBody('');
    obj.hide();
}
 /*** END PANEL ***/
 

 
 function switchFP(){
    var ar2Hide = ['hm2', 'sp_cont']
    var ar2show = ['hm', 'cl', 'wc', 'special', 'fp_cont']     // var ar2show = ['hm','pf', 'cl', 'wc', 'special', 'fp_cont']
}

/** splash on click + unonload of the page**/
function ClearCo(){
    /** do nothing **/
    /** this function was added to handle the unonload event on splash frontpage
         because of bug with the back button in Firefox & Safari
      **/
}

function GoLoad(o,id){
    // this line id for the test. remove it after.
   // if ( !(id==10 || id==21 || id==22)) return;
   
    if (!YesNoToBool(bShowLoadLbL)) return;
   
    if (o) {
        var tagt = o.parentNode.target;
        if (tagt=='' || tagt=='_self')   {
            z = YAHOO.util.Dom.getDocumentHeight();
            GE('loadMask').style.height = z+'px';
            GE('loadingBlock').style.visibility='visible';
        }
   }else {
        z = YAHOO.util.Dom.getDocumentHeight();
        GE('loadMask').style.height = z+'px';
        GE('loadingBlock').style.visibility='visible';
   }
}
function HideLoad(){
     GE('loadMask').style.height = '10px';
     GE('loadingBlock').style.visibility='hidden';
}

function SetSplashThumbs(){

    var nodes, i;
    var parBox = GE('feature');
    if (parBox){
        nodes = YAHOO.util.Dom.getElementsByClassName("thumb_splash", null, parBox)
        for (i=0; i<nodes.length; i++)
            if (i%2 == 0) AddClearBox(parBox, nodes[i]);
    }
    parBox = GE('non-feature');
    if (parBox){
        nodes = YAHOO.util.Dom.getElementsByClassName("thumb_splash", null, parBox)
        for (i=0; i<nodes.length; i++)
            if (i%3 == 0) AddClearBox(parBox, nodes[i]);
    }
}

function AddClearBox(x, z){
    var y;
    y = document.createElement('div');
    y.className = 'clearboth';
    x.insertBefore(y,z)
}


/*** price functions **/
var actPriceNum = 1;
function ShowHidePrice(num){
    if (actPriceNum == num) return;

    GE('po_'+actPriceNum).style.display = 'none';
    GE('ap'+actPriceNum).className="";
	GE('po_'+num).style.display = 'block';
	GE('ap'+num).className = "active";

    actPriceNum = num;
    
 }


/** end price functions **/

//** get Comment Box javascript file content
function getComBoJSContent(p){
    var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img; 
    var sRe = /(?:<script.*?>)/i;
    var srcRe = /\ssrc=([\'\"])(.*?)\1/i;   
    
    var match, sTagMatch, srcMatch;
 
    while(match = re.exec(p)){
        sTagMatch = match[0].match(sRe);
        if (sTagMatch) {
            srcMatch = sTagMatch[0].match(srcRe);
            if(srcMatch && srcMatch[2]){
                var callbackS = function(){
                    var callback = {
                        success : function(o) {
                                var rst = o.responseText;
                               
                                
                        },
                        failure : function(o) { }
                    }
                    return callback;            
                };
                var connS = YAHOO.util.Connect.asyncRequest("GET", srcMatch[2], callbackS);
            }
        }
    }

}

function YesNoToBool(str){
    if (str =='yes') return true;
    else return false;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function changePaypalP(obj, num){
    var formid = obj.id;
    
    var item_name = $("#"+formid+" input[name='item_name']").attr("value").split('|')
    if (item_name.length>0) item_name = item_name[0].trim();
    
    $("#"+formid+" input[name='item_name']").attr("value", item_name +" | "+$("#"+formid+" input[name='ppinfo_"+num+"']").attr("value"));
	$("#"+formid+" input[name='item_number']").attr("value",num);
}
