var prev_job="";
var prev_id="";
var step=1;
var itm=1;
var pclick="noclick";
try
{
var prevElement = "";
var prevId = "";
// extend String object
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, "");
}

String.trim = function(str) {
    if (typeof (str) != "string")
        return str;
    return str.trim();
}

String.prototype.reverse = function() {
    var sReversed = "";
    for (var i = this.length - 1; i > -1; i--)
        sReversed += this.charAt(i);
    return sReversed;
}

String.reverse = function(str) {
    if (typeof (str) != "string")
        return str;
    return str.reverse();
}

String.isNullOrEmpty = function(str) {
    return (str == null || str.toString().length == 0);
}

//=============================================================
//	function: String.format()
//
//	description: replaces placeholders in input string with specified values
//
//	parameters:
//		i_sInput		-	string. input string containing placeholders in the format {0}, {1}, ..., {N}
//		i_sReplaceWith0	-	string. replacement value corresponding with {0} placeholders
//		i_sReplaceWith1	-	string. replacement value corresponding with {1} placeholders
//		...
//		i_sReplaceWithN	-	string. replacement value corresponding with {N} placeholders
//
//	examples:
//		String.format("My name is {0}, {1} {0}", "Bond", "James")
//		returns "My name is Bond, James Bond"
//
//	remarks:
//		literal {} must be escaped as {{}}, for example
//		String.format("Literal {{curlies}} and with placeholder {{{0}}}", "it works")
//		returns "Literal {curlies} and with placeholder {it works}"
//=============================================================
String.format = function() {
    if (arguments.length < 1)
        return "";
    else if (arguments.length == 1 || typeof (arguments[0]) != "string")
        return sInput;

    var sInput = arguments[0];

    // escape literal curlies i.e. "{{" and "}}"
    //sInput = sInput.replace(/({{)([^{}]*){(.*?)(}}})/g, "_DCURL1_$2{$3}_DCURL2_"); // handles {{{0}}} and {{ {0}}} but not {{{{0}}}} etc.
    //sInput = sInput.replace(/({{)(.*?)(}})/g, "_DCURL1_$2_DCURL2_"); // handle all other escaped curlies
    sInput = sInput.replace(/{{/g, "_DCURL1_");
    sInput = sInput.reverse().replace(/}}/g, "_DCURL2_".reverse()).reverse();

    // replace {n} with argument number n + 1
    for (var i = 1; i < arguments.length; i++) {
        var oReplacementReg = new RegExp('\\{' + (i - 1) + '\\}', 'g');
        sInput = sInput.replace(oReplacementReg, arguments[i]);
    }

    // unescape literal curlies
    //sInput = sInput.replace(/(_DCURL1_)(.*?)(_DCURL2_)/g, "{$2}");
    sInput = sInput.replace(/_DCURL1_/g, "{").replace(/_DCURL2_/g, "}");

    return sInput;
}

//=============================================================
//	function: String.random()
//
//	description:
//		create a random string
//
//	input parameters:
//		i_iStrLength	-	int. return string length
//
//	return value:
//		string. randomized string
//=============================================================
String.random = function(i_iStrLength) {
    var sChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var sRandom = "";
    for (var i = 0; i < i_iStrLength; i++) {
        var iRandomNum = Math.floor(Math.random() * sChars.length);
        sRandom += sChars.charAt(iRandomNum);
    }
    return sRandom;
}

/*
* preloading an image. creating an image object with given source
* imgObj: name of object to be created
* imgSrc: URL of image 
*/
function preload(imgObj, imgSrc) {
    if (document.images) {
        eval(imgObj + ' = new Image()');
        eval(imgObj + '.src = "' + imgSrc + '"');
    }
}

/*
* This function receives a comma separated string where each
* pair is an image object name and an image URL.
* the function then goes over these pairs array and invokes the
* preload function to load the images into the browser's memory
*/
function preloadThem(str) {
    var arr = str.split(/\s*,\s*/)
    for (i = 0; i < arr.length; i += 2) {
        //alert(arr[i]+"\n"+arr[i+1])
        preload(arr[i], arr[i + 1])
    };
}

/*
* Used to invoke preloadThem() function.
* Please read the preloadThem() documentation.
*/
function preloadImages(str) {
    document.onload = preloadThem(str);
}

/*
* change a layer's image elemnt's source
* layer: name of a non nesting layer. if null look for image in document.images
* img: name of image element or an image object (or input type="image")
* imgObjName: name of preloaded image object
* -> image element of layer source would be replaced with image object's source
*/
function changeImage(img, imgObjName, layer) {
    var imgObjSrc = eval(imgObjName + ".src");
    // handle image object
    if (typeof (img) == 'object')
        img.src = imgObjSrc
    // handle image name
    else if (document.images && typeof (img) == 'string') {
        if (document.all || document.getElementById || layer == null)
            document.images[(img)].src = imgObjSrc;
        else eval('document.' + layer + '.document.images["' + img + '"].src = ' + imgObjSrc);
    }
}

// parse file name from file's path
function getFileName(filePath) {
    var p = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'))
    return filePath.substring(p + 1, filePath.length)
}

// This function opens a new window in the middle of the screen
// Parameters:
// w - the width of the window
// h - the height of the window
// ur - the URL of the window
// target - optional target of the window
// params - optional window parameters
function openwindow(w, h, ur, target, params) {
    var winleft = screen.width / 2 - w / 2
    var wintop = screen.height / 2 - h / 2 - 30
    var fullParams = 'width=' + w + ',height=' + h + ',' + 'top=' + wintop + ',left=' + winleft + ','
    if (!params)
        params = 'scrollbars=auto,menubar=no,resizable=yes,toolbar=no,location=no,status=no'
    fullParams += params
    if (!target) target = ''
    var newWinObj = window.open(ur, target, fullParams)
    if (newWinObj) newWinObj.focus()
    return newWinObj
}

// return reference to an object.
// compatible with IE4 and above, NS6 and above
function getElementById(id) {
    if (document.getElementById)
        return document.getElementById(id)
    else if (document.all)
        return document.all(id)
    else
        return null
}

function getAncestorById(obj, id) {
    for (var oAncestor = obj; oAncestor != null && oAncestor.id != id; oAncestor = oAncestor.parentNode)
        ;
    return oAncestor;
}

function getDescendantsById(obj, id) {
    var oDescendants = null;

    if (obj == null)
        oDescendants = getElementById(id);
    else if (obj.all)
        oDescendants = obj.all[id];
    else if (obj.item)
        oDescendants = obj.item(id);
    else if (obj.getElementById)
        oDescendants = obj.getElementById(id);
    else if (obj.getElementsByTagName)
        oDescendants = Array.filter(obj.getElementsByTagName("*"),
			function(elem) {
			    return elem.id == id;
			});

    if (oDescendants != null && oDescendants.length == undefined)
        oDescendants = [oDescendants];

    return oDescendants;
}

function getSingleDescendantById(obj, id) {
    var oDescendants = getDescendantsById(obj, id);
    if (oDescendants != null)
        return oDescendants[0];
    return null;
}

// display number with given precision
// returns a string
function precision(num, p) {
    if (!p || isNaN(num) || num.length == 0)
        return num
    num *= Math.pow(10, p)
    num = Math.round(num)
    num = num * 10 + 1
    num /= Math.pow(10, p + 1)
    num = num.toString()
    num = num.substring(0, num.length - 1)
    return num
}

// trim long strings to a limit of chars and replace with ...
function RTrimWith3dots(str, nChars) {
    var reg = new RegExp('^(.{' + (nChars - 3) + '})(.{4,})$')
    if (reg.test(str))
        str = str.replace(reg, '$1...')
    return str
}

//=============================================================
//	Function: Decode()
//
//	description:
//		an inline select case function which accept a variant
//		arguments length. function itereate through arguments list,
//		built of compare value, return value pairs, and compare each
//		compare value to its first argument. if a match is found its
//		following return value is returned. function must get at least
//		3 arguments.
//
//	input parameters:
//		i_vCompare			- variant. all compare values are matched to first argument
//		i_vCompareTo1		- variant. 1st compare value
//		i_vRetVal1			- variant. 1st return value
//		...
//		i_vCompareToN		- variant. N-th compare value
//		i_vRetValN			- variant. N-th return value
//		i_vDefaultRetVal	- variant. optinal default return value. returned if no match is found
//
//	return value:
//		variant
//=============================================================
function Decode(/*
	i_vCompare, 
	i_vCompareTo1, i_vRetVal1, ..., i_vCompareToN, i_vRetValN, 
	i_vDefaultRetVal
	*/) {
    if (arguments.length < 3)
        return;

    var vCompare = arguments[0];
    var vCompareTo, vRetVal;

    // go through <compare to, return value> pairs. if a match is found return the
    // following return value
    for (var i = 1; i + 1 < arguments.length; i += 2) {
        vCompareTo = arguments[i];
        vRetVal = arguments[i + 1];
        if (vCompare == vCompareTo)
            return vRetVal;
    }

    // return optional default return value
    return arguments[i];
}

function debug() {
    var str = '';
    do {
        str = prompt('input exp:', str);
        if (str)
            alert(str + ': ' + eval(str));
    } while (str.length > 0);
}

// get html elements offset top and left relative to window
// function returns an object with left and top properties
function getElementOffset(oElement) {
    var oReturnObj = new Object();

    oReturnObj.left = 0;
    oReturnObj.top = 0;
    while (oElement) {
        oReturnObj.left += oElement.offsetLeft;
        oReturnObj.top += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }

    return oReturnObj;
}

// handle ilegal chars in url search parameter's value (?param1=value1&param2=value2)
// ilegal chars are: '&', '+', ' ', ','
// ilegal chars are replaced using the myEscape function
// cannot use the escape function since it converts hebrew characters to utf-8
function urlParam(str) {
    var tmp = ''
    if (typeof (str) == 'string') {
        for (var i = 0; i < str.length; i++)
            tmp += myEscape(str.charAt(i))
    }
    return tmp
}

function myEscape(ch) {
    switch (ch) {
        case '&':
        case ' ':
        case ',':
        case '=':
        case '?':
        case '%':
        case '#':
            return escape(ch);
        case '+':
            return '%2b'; // escape('+') == '+' and '+' converted to ' ' in url
        default:
            return ch;
    }
}

//=============================================================
//	function: resizeToFitContent()
//
//	description: fit window width and height to content
//
//	input parameters:
//		i_sObjId		-	string. object id by which window is to be extended. object must
//							be specified with style "overflow:hidden; width:100%; height:100%;"
//		i_bVerticalOnly	-	boolean. optional flag indicating whether resize should be applied
//							in vertical direction only. false by default
//=============================================================
function resizeToFitContent(i_sObjId, i_bVerticalOnly) {
    var oContentContainer = document.getElementById(i_sObjId);
    if (!oContentContainer)
        return;

    i_bVerticalOnly = (i_bVerticalOnly == true);

    if (oContentContainer.scrollWidth > oContentContainer.offsetWidth || oContentContainer.scrollHeight > oContentContainer.offsetHeight) {
        var iWidthDiff = i_bVerticalOnly ? 0 : oContentContainer.scrollWidth - oContentContainer.offsetWidth;
        var iHeightDiff = oContentContainer.scrollHeight - oContentContainer.offsetHeight;
        if (!window.dialogHeight) {
            window.resizeBy(iWidthDiff, iHeightDiff);
            window.moveBy(-iWidthDiff / 2, -iHeightDiff / 2);
        }
        else {
            window.dialogHeight = (parseInt(window.dialogHeight) + iHeightDiff) + 'px';
            window.dialogTop = (parseInt(window.dialogTop) - iHeightDiff / 2) + 'px';
            if (!i_bVerticalOnly) {
                window.dialogWidth = (parseInt(window.dialogWidth) + iWidthDiff) + 'px';
                window.dialogLeft = (parseInt(window.dialogLeft) - iWidthDiff / 2) + 'px';
            }
        }
    }
}

//=============================================================
//	function: addFavorite()
//
//	description: add page to favorites
//
//	input parameters:
//		i_sUrl		-	string. optional favorite URL. if not specified then location.href will be used
//		i_sTitle	-	string. optional favorite title. if not specified then window.title will be used
//=============================================================
function addFavorite(i_sUrl, i_sTitle) {
    var sUrl = i_sUrl || location.href;
    var sTitle = i_sTitle || window.title;

    if (window.sidebar) // Mozilla Firefox Bookmark
        window.sidebar.addPanel(sTitle, sUrl, "");
    else if (window.external) // IE Favorite
        window.external.AddFavorite(sUrl, sTitle);
    else if (window.opera && window.print) // opera
    {
        var oElem = document.createElement("a");
        oElem.setAttribute("href", sUrl);
        oElem.setAttribute("title", sTitle);
        oElem.setAttribute("rel", "sidebar");
        oElem.click();
    }
}

//=============================================================
//	function: setHomePage()
//
//	description: set page as default browser's home page IE only!!
//=============================================================
function setHomePage() {
    if (document.body && document.body.style && document.body.style.behavior) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(window.location.href);
    }
}
function openStage1(id, curElem) {
    if (document.getElementById(id).className == "hide") {
        document.getElementById(id).className = "show";
        curElem.className = "header_top_search_item_over";
    }
    else {
        document.getElementById(id).className = "hide";
        curElem.className = "header_top_search_item";
    }
    if (prevElement != "" && prevElement != curElem) {
        document.getElementById(prevId).className = "hide";
        prevElement.className = "header_top_search_item";
    }
    prevId = id;
    prevElement = curElem;
}

function stageOver(id, overClass) {

    //alert(overClass);
    document.getElementById(id).className = overClass;

}

/*
//
// Service Points Map Scripts
//
*/


/** ---------------------------------------------------------------------
* Implements cookie-less JavaScript session variables
* v1.0
*
* By Craig Buckler, Optimalworks.net
*
* As featured on SitePoint.com
* Please use as you wish at your own risk.
*
* Usage:
*
* // store a session value/object
* Session.set(name, object);
*
* // retreive a session value/object
* Session.get(name);
*
* // clear all session data
* Session.clear();
***---------------------------------------------------------------------
*/

if (JSON && JSON.stringify && JSON.parse) var Session = Session || (function() {
// window object
    var win = window.top || window;

    // session store
    var store = (win.name ? JSON.parse(win.name) : {});

    // save store on page unload
    function Save() {
        win.name = JSON.stringify(store);
    };

    // page unload event
    if (window.addEventListener) window.addEventListener("unload", Save, false);
    else if (window.attachEvent) window.attachEvent("onunload", Save);
    else window.onunload = Save;

    // public methods
    return {

        // set a session variable
        set: function(name, value) {
            store[name] = value;
        },

        // get a session value
        get: function(name) {
            return (store[name] ? store[name] : undefined);
        },

        // clear session
        clear: function() { store = {}; },

        // dump session data
        dump: function() { return JSON.stringify(store);
     }

    };

})();
}
catch(e)
{
}

var varLastOpenedDetailsID="";
var varlastOpenedPlusID="";

function openCloseDetails(current, button, buttonImageSrc, regionTitle,btnplussrc) {
	
    //close previously opened details section IF it is not the same section again
    
    if (varLastOpenedDetailsID!=""){    
     document.getElementById(varLastOpenedDetailsID).style.visibility = "hidden";
	 document.getElementById(varlastOpenedPlusID).src=btnplussrc;
    }
   

	/*
    if (1==0){
    if (Session.get("lastOpenedDetails") != null && Session.get("lastOpenedDetails") != current) {
        var lastOpenedDetailsID = Session.get("lastOpenedDetails");
        var lastOpenedPlusID = Session.get("lastOpenedPlus");
        var lastOpenedTitleID = Session.get("lastOpenedTitle");
        document.getElementById(lastOpenedDetailsID).style.visibility = "hidden";
        document.getElementById(lastOpenedPlusID).setAttribute("src", btnplussrc);
        //document.getElementById(lastOpenedPlusID).style.zIndex=6;
        }
    
    }
    */
	
	 if (varLastOpenedDetailsID!=current)
    {
	
    //First time click
    if (document.getElementById(current).style.visibility == "") 
    {
        //alert("Opening 1st time now!");
        document.getElementById(current).style.visibility = "visible";
        document.getElementById(current).style.zIndex=10;
        document.getElementById(button).setAttribute("src", buttonImageSrc);
        //document.getElementById(button).style.zIndex=40;
  
    }
    else 
    { 
        //update current button and details-div
        if (document.getElementById(current).style.visibility == "hidden") {
            //alert("Opening now!");
            document.getElementById(current).style.visibility = "visible";
            document.getElementById(current).style.zIndex=10;
            document.getElementById(button).setAttribute("src", buttonImageSrc);
            //document.getElementById(button).style.zIndex=40;
            
        }
        else if (document.getElementById(current).style.visibility == "visible") {
            //alert("Closing now!");
            document.getElementById(current).style.visibility = "hidden";
            //document.getElementById(current).style.zIndex=6;
            document.getElementById(button).setAttribute("src", btnplussrc);
            //document.getElementById(button).style.zIndex=6;            
        }
    }
    
   
		varLastOpenedDetailsID=current;
		varlastOpenedPlusID=button;    
    }
    else{
    varLastOpenedDetailsID="";
    varlastOpenedPlusID="";
    }
    
    //save opened details section to Session
    //Session.clear();
    //Session.set("lastOpenedDetails", current);
    //Session.set("lastOpenedPlus", button);
    //Session.set("lastOpenedTitle", regionTitle);
}

function ClearSessionA() {
    Session.clear();
    //alert("clearing session");
}

/*
//
// END OF Service Points Map Scripts
//
*/
/****hide last row sepearator from repeater for product 3 in line****/
function hideLastSep(counter,elemString){
var lastIndex=counter-1;
if(counter%3==0){
document.getElementById(elemString+lastIndex).className="Products_MainZone_3_INLINE_last";
}

}

function PrintItem(objItem,siteName,strParams){
objItem=document.getElementById(objItem);
var cssPath='<LINK rel="stylesheet" type="text/css" href="/metromotors/SVTemplate/css/style.css"/>';
var defaultParams = 'toolbar=no,menubar=no,fullscreen=no ,scrollbars=yes,resizable=yes,width=560,height=575,top=10,left=10';
      var ItemWin;
      if(strParams!=null)
      {
      ItemWin = window.open('','_blank',strParams);
      }
      else
      {
      ItemWin = window.open('','_blank',defaultParams);
      }

      var myDoc = objItem.innerHTML ;
     
      //alert(myDoc);
      ItemWin.document.open();
      
      ItemWin.document.write('<HTML><HEAD>'+cssPath+'</HEAD><BODY style="background:#FFFFFF"><TABLE  width="100%"><TR><TD style="padding:5px;" dir="rtl">' + myDoc + '</TD></TR></TABLE></BODY></HTML>' );
      ItemWin.document.close();
      ItemWin.print();
      ItemWin.close();
  }
  //==============================================================
  //	FUNCTIONS FOR POPUP
  //==============================================================
  function popup_show(id) {
      var oFlyWindow = document.getElementById(id);
      var oHider = PioEffects.getContetsFader();
      oHider.open();

      oFlyWindow.style.display = "";
      popup_makePosition(oFlyWindow);
      oFlyWindow.style.visibility = "visible";
      oFlyWindow.previousSibling.value = "False";
  }
  function popup_hide(id) {
      var oFlyWindow = document.getElementById(id);
      if (oFlyWindow == null) return false;

      oFlyWindow.style.visibility = "hidden";
      oFlyWindow.style.display = "none";
      oFlyWindow.previousSibling.value = "True";

      var oHider = PioEffects.getContetsFader();
      oHider.close();
  }
  function popup_makePosition(flyWindow) { //@@@ private function
      if (typeof (flyWindow) == "string") {
          flyWindow = document.getElementById(flyWindow);
      }
      if (flyWindow == null) return;
      var iX = (document.body.clientWidth - flyWindow.offsetWidth) / 2;
      var iY = (document.body.clientHeight - flyWindow.offsetHeight) / 2;
      var scrollTop = document.getElementsByTagName('body')[0].scrollTop + iY;
      if (PioWeb.BrName == "IE") {
          flyWindow.style.left = iX + "px";
          flyWindow.style.top = scrollTop + "px";
//          flyWindow.style.setExpression("top", "document.getElementsByTagName('body')[0].scrollTop+" + iY + "+'px'");
      } else {
          flyWindow.style.left = iX + "px";
          flyWindow.style.top = iY + "px";

          //@@@ prevent blinking in MZ
          var oFld = flyWindow.previousSibling;
          oFld.form.elements[flyWindow.id + "__mztop"].value = iY;
          oFld.form.elements[flyWindow.id + "__mzleft"].value = iX;
      }
  }
  function popup_pageLoaded(sender, args) { //@@@ used for ajax.net assync claaback
      if (_ar_oPopupRegistres != null) {
          for (var i = 0; i < _ar_oPopupRegistres.length; i++) {
              var sId = _ar_oPopupRegistres[i];
              var ctlHideTag = document.getElementById(sId + "__hidetag");
              if (ctlHideTag != null) {
                  var oHider = PioEffects.getContetsFader();
                  oHider.close();
                  break;
              }
          }
          for (var i = 0; i < _ar_oPopupRegistres.length; i++) {
              var sId = _ar_oPopupRegistres[i];
              var ctlShowTag = document.getElementById(sId + "__showtag");
              if (ctlShowTag != null) {
                  popup_show(sId);
              }
              var ctlShowTag = document.getElementById(sId + "__showntag");
              if (ctlShowTag != null) {
                  popup_makePosition(sId);
              }
          }
      }
  }
  var _ar_oPopupRegistres = new Array();

  //==============================================================
  //	FUNCTIONS FOR POPUP
  //==============================================================

function show_job(id)
{
	if(document.getElementById("job_detail"+id).className=="job_hide"){
	   document.getElementById("job_detail"+id).className="job_show";
	   document.getElementById("job"+id).className="job_selected"; 
	   
	}
	else{
	 document.getElementById("job_detail"+id).className="job_hide";
	 document.getElementById("job"+id).className="jobs";
	}
	if(prev_job!="" &&prev_job!=id){
	    document.getElementById("job_detail"+prev_job).className="job_hide";
	     document.getElementById("job"+prev_job).className="jobs";
	}
	prev_job=id;
}
function modelsSetActive(id)
{
//alert(id);
	if(document.getElementById("body"+id).className=="hide"){
	   document.getElementById("body"+id).className="prods_accordion_bg";
	   //title
	   document.getElementById("title"+id).className="prod_accordion_container_title_open";
	}
	else{
	 document.getElementById("body"+id).className="hide";
	  document.getElementById("title"+id).className="prod_accordion_container_title";
	}
	//if(prev_id!="" && prev_id!=id){
	//    document.getElementById("body"+prev_id).className="hide";
	//     document.getElementById("title"+prev_id).className="prod_accordion_container_title";
	//}
	//prev_id=id;
}
function fnVisibleSelect(attribute)
{
    try {
        var element;
        var flgForm = false;
        var flgSelect = false;
        var sBrowser = PioWeb.BrName == "IE" ? "ie" : "ff";

        var elements = (document.all) ? document.all : document.getElementsByTagName("*");
        for (var i = 0; i < elements.length; i++)   
        {
            element = elements[i];
            switch (element.tagName)     
            {
                case 'DIV':
                    if (element.className == "panel-form")
                        flgForm = true;
                    break;
                case 'SELECT':
                    if (flgForm) {
                        element.style.display = attribute;
                        elements[i - 5].className += (" pio-form-display-" + sBrowser + "-" + attribute);
//                        elements[i - 5].style.display = attribute;
                        flgSelect = true;
                    }
                    break;
            }
            if (flgSelect) break;
          }
     }
     catch (e) {}
}
function fn_attach_new_question(img) {
     var new_question_btn = document.getElementById("new_question_btn");
     if (new_question_btn.className == "new-question")
     {
        try {
            if (document.getElementById("new_question_form").innerHTML != "")
                document.getElementById("new_question_div").innerHTML = document.getElementById("new_question_form").innerHTML;
            document.getElementById("new_question_form").innerHTML = "";
            new_question_btn.className = "new-question-opened";
        }
        catch (e) { }
     }
     else {
         try {
            document.getElementById("new_question_form").innerHTML = document.getElementById("new_question_div").innerHTML;
            document.getElementById("new_question_div").innerHTML = "";
            new_question_btn.className = "new-question";
        }
        catch (e) {alert(e.description); }
    }
   
}
 function switchMidPic(f_name,suffix,curId){
   document.getElementById("medum_pic"+curId).src=f_name+"mid"+suffix;
   $("#larg_pic"+curId).attr('rel',f_name+suffix);
    }
 function  closeHandsPopup(){
	document.getElementById("image_popup").innerHTML="";
	$("#image_popup").attr("class", "hide");
	$("#fade").hide();
 }
 function showHandsPopup(curId){
 var result_window="<div class='imagePopWindow'><div class='imagePopUpClose' id='hands_popup_close' onclick='closeHandsPopup()'><img src='SVTemplate/img/general/hands_close.gif' vspace='3'/></div><img src='"+ $("#larg_pic"+curId).attr('rel')+"'</div>";
	document.getElementById("image_popup").innerHTML=result_window;
	$('#fade').fadeIn(1000);	
	$('#fade').fadeTo("fast",0.8);	
$("#image_popup").attr("class", "image_popup");		 
$("#image_popup"). css("top",parseInt($("#start_height").val())+(40*curId)); 
 }
 
  function slideImage(direction,Id){
   if(pclick!=direction)
    step=1;
    
    var s = $("#"+Id+" li").size();
  
			var w = $("#"+Id+" li").width(); 
			var h = $("#"+Id+" li").height();
			var offset = $("#"+Id+" ul").offset();  
			$("#"+Id+" ul").css('width',s*w);
			$("#"+Id+" ul").css('height',h);
		
			if(direction=="next"){
			if(itm==s){
			 $("#"+Id+" ul").animate({"right":"0px"},{ "duration": "slow", easing: "easeInOutExpo"});
			 itm=1;
			 step=1;
			 
			 }
			else{
			$('#'+Id+' ul li:nth-child('+itm+')').clone().insertAfter('#'+Id+' ul li:nth-child('+s+')');
     $("#"+Id+" ul").animate({"right":"+=" +"-"+w+"px"},{ "duration": "slow", easing: "easeInOutExpo"});
     step+=1;
     itm++;
     pclick="next";
     }
     }
     else{
     if(itm==1)
     {
          $("#"+Id+" ul").animate({"right":"-"+w*(s-1)+"px"},{ "duration": "slow", easing: "easeInOutExpo"});
          itm=s;
          step=1
     }
        else{
         $("#"+Id+" ul").animate({"right":"+=" +w+"px"},{ "duration": "slow", easing: "easeInOutExpo"});
     step-=1;
     itm--;
     }
      
     pclick="prev";
    }
      
    }
    
 
