/************************************************************************/
/*							Constants and variables						*/
/************************************************************************/
var sFP = window.location.protocol + "//" + window.location.host;
try {var sNUI = (new Cookie("NUI")).getCookie().replace(/[+]/g,' ');}catch(ex){}

/************************************************************************/
/*			  				Prototipes and object functions				*/
/************************************************************************/
function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}

String.prototype.trim = function(){
	return trim(this);
}

function randOrd(a, b){
	return (Math.round(Math.random())-0.5); 
}

function dec2hex(n){
	n = parseInt(n); var c = 'ABCDEF';
	var b = n / 16; var r = n % 16; b = b-(r/16); 
	b = ((b>=0) &&  (b <= 9)) ? b : c.charAt(b-10);    
	return ((r>=0) && (r <= 9)) ? b+''+r : b+''+c.charAt(r-10);
}
	
function UrlEncode(sStr)
{
	var sReturn='';
	for (var i=0;i<sStr.length;i++)
	{
		var iUni=sStr.charCodeAt(i);
		if(iUni>=1488 && iUni<=1514)
		{
			var iAsc=iUni-1264 ;
			sReturn+=escape(String.fromCharCode(iAsc));
		}
		else if(iUni==32) sReturn += escape('+');
		else if(iUni==43) sReturn += '%2b';
		else	sReturn+=escape(sStr.charAt(i));
	}
	return sReturn;
}

function utf8_decode(utftext) {
	var string = "";
	var i = 0;
	var c = c1 = c2 = 0;

	while ( i < utftext.length ) {

		c = utftext.charCodeAt(i);

		if (c < 128) {
			string += String.fromCharCode(c);
			i++;
		}
		else if((c > 191) && (c < 224)) {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}
		else {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}

	}

	return string;
}

function suycDateDiff(start) {
	// This function need to recieve date in format = 20:06 25/12/2001
	// and return how many days it is from today
	var strMonthArray = new Array(12);
	strMonthArray[0]  = "Jan";
	strMonthArray[1]  = "Feb";
	strMonthArray[2]  = "Mar";
	strMonthArray[3]  = "Apr";
	strMonthArray[4]  = "May";
	strMonthArray[5]  = "Jun";
	strMonthArray[6]  = "Jul";
	strMonthArray[7]  = "Aug";
	strMonthArray[8]  = "Sep";
	strMonthArray[9]  = "Oct";
	strMonthArray[10] = "Nov";
	strMonthArray[11] = "Dec";
	
	var text = start.substring(5);	
	
	// the mounth
	var sMounth = text
		sMounth = text.substring(3);
		sMounth = sMounth.substring(1,3) ;
	    if(sMounth.indexOf(0)==0) sMounth = sMounth.substring(1,2);
	     sMounth = strMonthArray[sMounth-1];
	     
	// the day
	var sDay = text;
		sDay = sDay.substring(1,3) ;	
	
	// the year
	var sYear = text ;
	    sYear = sYear.substring(7,11) ;
	
	// all start string again
	start = sDay + " " + sMounth + " " + sYear ;	    	

	var now;
	now  = new Date() ;		
    var iOut = 0;
    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( now ) ;    	
    if ( isNaN (bufferA) || isNaN (bufferB) )   return 0 ;            	                        
    var number = bufferB-bufferA ;       
    iOut = parseInt(number / 86400000) ;                  
    return iOut ;
}

/************************************************************************/
/*							Search functions							*/
/************************************************************************/

function defined(o) 
{
	return (typeof(o)!="undefined");
}

function SearchRedirectLocal(e)
{
 if (!defined(e) && defined(window.event)) {
      e = window.event;
  }
  return SearchRedirect(false, (e.target || e.srcElement));
}

function SearchRedirect(bReturnString, frm)
{
	var sParamName, sParamValue,arrSplit,sUrl='';
	var oSearchBar = (!defined(frm))?document.getElementById("SearchBar"):frm;
	var oDiv = new Div(oSearchBar);
	var oArrInput;
	var nNumOfParam = 0;
	var sKeywordParam;
	var sArrIgnore = new Array ('q','serviceAction');
	var arrURL, sOptionId;
	var oQ = oSearchBar.q;
	
	oQ = CleanKeywords(oQ);
		
	if(oQ.value.length < 2 || oQ.value== 'חפשו אתר')
	{
		alert("מילת חיפוש צריכה להכיל לפחות 2 תווים חוקיים"); 
		return false;
	}
	
	if(oSearchBar.serviceAction.value) {
		arrURL = oSearchBar.serviceAction.value.split("|");
	}
	else {
		var oSA = document.getElementsByName('serviceAction');
		for (var i=0;i<oSA.length;i++)
			if(oSA[i].checked)
			{
				sOptionId = oSA[i].id;
				arrURL=oSA[i].value.split("|");
				break;
			}
	}
	
	if(typeof(arrURL) != "undefined") {
		nNumOfParam=arrURL.length;	
	}
		
	// get extra parameters
	if(nNumOfParam > 2)
		for(var i=1;i<nNumOfParam-1;i++)
		{
			arrSplit=arrURL[i].split("=");
			sParamName=arrSplit[0];
			sParamValue=arrSplit[1];
			
			sUrl+='&' + escape(sParamName) + '=' + UrlEncode(sParamValue) ;
		}
	
	if(typeof(arrURL) != "undefined") {
		if(arrURL[0].toLowerCase().indexOf("ftsearch")>=0)
		{
			if(!ValidateSearchString(oQ.value.trim()))
			{
				alert(".מילת חיפוש יכולה להכיל אותיות באנגלית, עברית וספרות");
				return false;
			}
		}
	}
	//debugger;
	oArrInput=oSearchBar.getAllChild('INPUT');
	for (var i=0;i<oArrInput.length;i++)
		if(sArrIgnore[0]!=oArrInput[i].name && sArrIgnore[1]!=oArrInput[i].name )
			if ((oArrInput[i].type=='radio' && oArrInput[i].checked)||oArrInput[i].type!='radio')
				sUrl+='&' + escape(oArrInput[i].name) + '=' + UrlEncode(oArrInput[i].value)
			
	oArrInput=oSearchBar.getAllChild('SELECT');
	for (var i=0;i<oArrInput.length;i++)
		if(sArrIgnore[0]!=oArrInput[i].name && sArrIgnore[1]!=oArrInput[i].name )
			sUrl+='&' + escape(oArrInput[i].name) + '=' + UrlEncode(oArrInput[i].value) ;

	if(typeof(arrURL) != "undefined") {
		sKeywordParam = arrURL[nNumOfParam-1];
	}
	sUrl += '&gr=' 
	sUrl += oSearchBar.g.checked ? '1' : '0' ;
	
	sUrl=sUrl+'&' + escape(sKeywordParam) + '=' + UrlEncode(oQ.value) ;	
	
	if(typeof(arrURL) != "undefined") {
		sUrl= arrURL[0] + '?' +sUrl.substring(1);
	}
	else {
		sUrl= sUrl.substring(1);
	}
	
	if (sOptionId)
		sUrl += "&sbId=" + sOptionId.replace("serviceAction","");
	if (oQ.value!='')
		if (bReturnString)
			return sUrl;
		else {
			parent.location=sUrl ;
			return false;
		}
	else
		return false;		
}

function SelectSearchButton(){
	var sSrbId = RequestQueryString("sbId");
	if (sSrbId != "") {
		var oSrlOldId = document.getElementById("FontSelected1")
		var oSrlId = document.getElementById("FontSelected" + sSrbId)
		var oSrb = document.getElementById("serviceAction" + sSrbId);
		if (oSrb){
			oSrb.checked = true;
			oSrlOldId.style.fontWeight = "normal";
			oSrlId.style.fontWeight = "bold";
		}
	}
}

function ValidateSearchString(sStr){
    
    for (i=0;i<sStr.length;i++)   {
        var iChar=sStr.charCodeAt(i);
        if  (  
                !(
					(iChar==32 ) ||
                    (iChar>=97 && iChar<=122) ||
                    (iChar>=65 && iChar<=90) ||
                    (iChar>=48 && iChar<=57) ||
                    (iChar>=1488 && iChar<=1514) 
                )
            )
            {
                return false;
            }
    }
    return true    
}

function CleanKeywords(oKeyword) {
	var KeywordValue = oKeyword.value
	KeywordValue = KeywordValue.replace('http://', '');
	KeywordValue = KeywordValue.replace('www.', '');
    KeywordValue = KeywordValue.replace('.com', '');
    KeywordValue = KeywordValue.replace('.co', '');
    KeywordValue = KeywordValue.replace('.net', '');
    KeywordValue = KeywordValue.replace('.org', '');
    KeywordValue = KeywordValue.replace('.gov', '');
    KeywordValue = KeywordValue.replace('.net', '');
    KeywordValue = KeywordValue.replace('.il', '');
    KeywordValue = KeywordValue.replace('planet.nana', '');
    KeywordValue = KeywordValue.replace('members.nana', '');
    KeywordValue = KeywordValue.replace('.asp', '');
    KeywordValue = KeywordValue.replace('.htm', '');
    KeywordValue = KeywordValue.replace('.html', '');
    KeywordValue = KeywordValue.replace(/\?/g, ' ');
    KeywordValue = KeywordValue.replace(/!/g, ' ');
    KeywordValue = KeywordValue.replace(/;/g, ' ');
    KeywordValue = KeywordValue.replace(/\+/g, ' ');
    KeywordValue = KeywordValue.replace(/-/g, ' ');
    KeywordValue = KeywordValue.replace(/~/g, ' ');
    KeywordValue = KeywordValue.replace(/%/g, ' ');
    KeywordValue = KeywordValue.replace(/$/g, ' ');
    KeywordValue = KeywordValue.replace(/&/g, ' ');
    KeywordValue = KeywordValue.replace(/^/g, ' ');
    KeywordValue = KeywordValue.replace(/^/g, ' ');
    KeywordValue = KeywordValue.replace(/@/g, ' ');
    KeywordValue = KeywordValue.replace(/=/g, ' ');
    KeywordValue = KeywordValue.replace('/', ' ');
    KeywordValue = KeywordValue.replace(/\[/g, ' ');
    KeywordValue = KeywordValue.replace(/]/g, ' ');
    KeywordValue = KeywordValue.replace(/\(/g, ' ');
    KeywordValue = KeywordValue.replace(/\)/g, ' ');
    KeywordValue = KeywordValue.replace(/\*/g, ' ');
    KeywordValue = KeywordValue.replace(/#/g, ' ');
    KeywordValue = KeywordValue.replace(/}/g, ' ');
    KeywordValue = KeywordValue.replace(/{/g, ' ');
    KeywordValue = KeywordValue.replace(/,/g, ' ');
    KeywordValue = KeywordValue.replace(/</g, ' ');
    KeywordValue = KeywordValue.replace(/>/g, ' ');
	//alert(KeywordValue);
	oKeyword.value = trim(KeywordValue);
	return oKeyword;
}

function SearchNoValidateSubmit(){
	return true;
}

function DecodeKeyword(sKeyword) {
    var sNewKeyword = "";
    
    if (typeof (sKeyword) != "undefined") {
        var aWords = sKeyword.split("+");

        for (j = 0; j < aWords.length; j++) {
            var aLetters = aWords[j].split("%D7");
            if (aLetters.length > 1) {
                for (i = 1; i < aLetters.length; i++) {
                    sNewKeyword += "%" + dec2hex(parseInt("0x" + aLetters[i].substr(1, 2)) + 0x50);
                }
            }
            else {
                sNewKeyword += aWords[j];
            }
            if (j < aWords.length - 1) {
                sNewKeyword += "+";
            }
        }
    }
	return sNewKeyword;
}

/************************************************************************/
/*							Nana DOM and HTML functions					*/
/************************************************************************/
//Keep this function for backward compatibility
function NanaPopUp (sPopupWinArgs) {
	NanaPopUpReturn(sPopupWinArgs)
}

//This function return the refrence of the popup
//Usage:
//	NanaPopUpReturn ('TargetURL, width, height, scrollbars')
//Usage examples:
//	NanaPopUpReturn ('http://www.nana10.co.il, 400, 300, yes')
//	NanaPopUpReturn ('http://www.nana10.co.il, width=400, height=300, scrollbars=yes')
function NanaPopUpReturn (sPopupWinArgs) {					 
	if(sPopupWinArgs != '') {
		var sURL		= '';
		var sWidth		= '';
		var sHeight		= '';
		var sFeatures	= '';
		var sScrollBars	= '';
		
		var oNewWindow;					
		var sName = 'PopupWin';
		var sFeatures	= '';
		var arrArgs		= sPopupWinArgs.split(",");

		typeof(arrArgs[0]) == 'string' ? sURL = arrArgs[0] : {};
		if (typeof(arrArgs[1]) == 'string')
			sWidth = arrArgs[1].toLowerCase() 
		else {
			parent.location.href=sURL; 
			self.focus();
			return(null);
		}
		typeof(arrArgs[2]) == 'string' ? sHeight = arrArgs[2].toLowerCase() : {};
		typeof(arrArgs[3]) == 'string' ? sScrollBars = arrArgs[3].toLowerCase() : {};
		
		sFeatures = 'top=10, left=10';
		
		if (sWidth == "width=0") {
			sWidth = '';
		} else if (sWidth.indexOf('width')==-1) {
			sWidth = ', width=' + sWidth;
		} 
		
		if (sHeight == "height=0") {
			sHeight = '';
		} else if (sHeight.indexOf('height')==-1) {
			sHeight = ', height=' + sHeight;
		} 
		
		if (sScrollBars != '' && sScrollBars.indexOf('scrollbars')==-1) {
			sScrollBars = ', scrollbars=' + sScrollBars;
		} 

		sFeatures = sFeatures + sWidth + sHeight + sScrollBars
		
		oNewWindow = window.open (sURL,sName,sFeatures);
		return oNewWindow;
	}
}

// get query string paramter and return the value
function RequestQueryString(KeyName, qrStr) {
    if (typeof (qrStr) == "undefined") {
		var qrStr = window.location.search;
	}
	else {
		var arrHref = qrStr.split("?");
		qrStr = (arrHref.length < 2) ? arrHref[0] : arrHref[1];
	}

	var spQrStr = qrStr.substring(1);
	var arr = spQrStr.split("&");

	for (var i = 0; i < arr.length; i++) {
		// splits each of field-value pair
		var index = arr[i].indexOf("=");
		var key = arr[i].substring(0, index);
		var val = arr[i].substring(index + 1);

		if (key == KeyName)
			return val;
	}
}

function GetWindowWidth() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}

function GetWindowHeight() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myHeight = window.innerHeight;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

// This function save cookie - deprecated, use class
function saveCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000))		
		var expires = "; expires="+date.toGMTString()
	}
	else expires = ""
		document.cookie = name+"="+value+expires+"; path=/"				
}

// This function read the cookie that was saved by saveCookie function - deprecated, use class
function readCookie(name) {
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return 1;
}

function XmlLoader(source) {
    var xmlDoc;
    if (!source.documentElement) {
        source = source || '<root></root>';
        try {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.loadXML(source);
        }
        catch (e) {
            try {
                parser = new DOMParser();
                xmlDoc = parser.parseFromString(source, "text/xml");
            }
            catch (e) {
                // alert(e.message);
                return null;
            }
        }
        source = xmlDoc;
    }
    return source;
};


/************************************************************************/
/*							Nana functionality							*/
/************************************************************************/

function displayWallashopsTemplate(sTargetId, sTemplateId){
	$(function(){
		if(typeof oWsProducts != "undefined")
		{
			if(typeof oWsProducts.error == "undefined")
			{
				oWsProducts.vertical_template.sort(randOrd);
				oWsProducts.main_template.sort(randOrd);
				oWsProducts.horizontal_template.sort(randOrd);
				$("#" + sTargetId).setTemplateElement(sTemplateId,null,{filter_data: false});
				$("#" + sTargetId).processTemplate(oWsProducts);
			}
		}
	});
}

function SetGirafaCheckbox(flag, Formobject){
	if (flag) {
		Formobject.gr.value=1;
	}
	else {
		Formobject.gr.value=0;
	}
}

var naPageRefreshEnabled = true;

function SetPageRefresh(iTimeoutInterval){
	if (iTimeoutInterval > 0){
		window.setTimeout(function(){PerformPageRefresh(iTimeoutInterval);},iTimeoutInterval);
	}
}

function PerformPageRefresh(iTimeoutInterval){
	//Perform page refresh or set another try after interval
	if (naPageRefreshEnabled){
		document.location.href = document.location.href;
	}
	else {
		window.setTimeout(function(){PerformPageRefresh(iTimeoutInterval);},iTimeoutInterval);
	}
}

function TogglePageRefresh(bVal){
	naPageRefreshEnabled = bVal;
}

function CheckSurveyType1Form()	{
	var bFormFilled = true; 
	var bQuestionFilled = false;

	for (i=0; i<document.getElementsByName("QuestionID").length; i++)
	{
		bQuestionFilled = false;

		for (j=0; j<document.getElementsByName(document.getElementsByName("QuestionID")[i].value).length; j++)
		{
			if (document.getElementsByName(document.getElementsByName("QuestionID")[i].value)[j].checked == true) {
				bQuestionFilled = true;
				break;
			}
		}
		if ( bQuestionFilled != true){
			bFormFilled = false;
			break;
		}
	}
	return bFormFilled;
}
	
function CheckSurveyType2Form()	{	
	if(CheckSurveyType1Form()) {	
		if ( document.getElementById("FirstName").value!='' && document.getElementById("LastName").value!='' && document.getElementById("Address").value!='' && 	(new Input(document.getElementById("Email")).CheckEmail()) ) 
				{	
					new Div (document.getElementById("oMsg")).Open();
					new Div (document.getElementById("oMsgBold")).Close();
					return true;
				}
				else 
				{
					if (document.getElementById("FirstName").value=='' || document.getElementById("LastName").value=='' || document.getElementById("Address").value=='' )
						document.getElementById("oMsgBold").innerHTML="נא למלא את כל השדות המסומנים בכוכבית";
					else 
						document.getElementById("oMsgBold").innerHTML="שדה דואר אלקטרוני לא תקין";
					
					new Div (document.getElementById("oMsg")).Close();
					new Div (document.getElementById("oMsgBold")).Open();
					return false;
				}
			}
	document.getElementById("oMsgBold").innerHTML="אנא השב על כל השאלות.";
	new Div (document.getElementById("oMsg")).Close();		
	new Div (document.getElementById("oMsgBold")).Open();
	return false;
}


function PopUpResizeTicker() {
	var iWidth=496;
	var iOffsetY=90;
	window.moveTo(0,0);
	window.resizeTo(iWidth,(new Div(document.getElementById("oTickerBody")).getHeight())+iOffsetY);
	window.focus();		
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }

 function OpenGameWindow(sLink, sTitle) {
     
	sTitle = sTitle.replace("'", "`");
	var typeid = RequestQueryString("typeid", sLink);
	if (typeid == "" || typeof (typeid) == "undefined") {
		sLink += "&typeid=5";
	}
	else if(typeid != 5 && typeid != ""){
		sLink = sLink.replace("typeid=" + typeid, "typeid=5");
	}
	window.open(sLink + "&GameN=" + sTitle, "", "width=1024,height=910,resizable=1,scrollbars=1");	
}

/************************************************************************/
/*							Plugin detection							*/
/************************************************************************/
var PluginDetect = {
    handler: function(c, b, a) {
        return function() {
            c(b, a)
        }
    },
    isDefined: function(b) {
        return typeof b != "undefined"
    },
    isArray: function(b) {
        return (b && b.constructor === Array)
    },
    isFunc: function(b) {
        return typeof b == "function"
    },
    isString: function(b) {
        return typeof b == "string"
    },
    num: function(a) {
        return (this.isString(a) && (/\d/).test(a))
    },
    getNumRegx: /[\d][\d\.\_,-]*/,
    splitNumRegx: /[\.\_,-]/g,
    getNum: function(b, c) {
        var d = this, a = d.num(b) ? (d.isDefined(c) ? new RegExp(c) : d.getNumRegx).exec(b) : null;
        return a ? a[0].replace(d.splitNumRegx, ",") : null
    },
    compareNums: function(h, f, d) {
        var e = this, c, b, a, g = parseInt;
        if (e.num(h) && e.num(f)) {
            if (e.isDefined(d) && d.compareNums) {
                return d.compareNums(h, f)
            }
            c = h.split(e.splitNumRegx);
            b = f.split(e.splitNumRegx);
            for (a = 0; a < Math.min(c.length, b.length); a++) {
                if (g(c[a], 10) > g(b[a], 10)) {
                    return 1
                }
                if (g(c[a], 10) < g(b[a], 10)) {
                    return -1
                }
            }
        }
        return 0
    },
    formatNum: function(b) {
        var c = this, a, d;
        if (!c.num(b)) {
            return null
        }
        d = b.replace(/\s/g, "").split(c.splitNumRegx).concat(["0", "0", "0", "0"]);
        for (a = 0; a < 4; a++) {
            if (/^(0+)(.+)$/.test(d[a])) {
                d[a] = RegExp.$2
            }
        }
        if (!(/\d/).test(d[0])) {
            d[0] = "0"
        }
        return d.slice(0, 4).join(",")
    },
    $$hasMimeType: function(a) {
        return function(d) {
            if (!a.isIE) {
                var c, b, e, f = a.isString(d) ? [d] : d;
                for (e = 0; e < f.length; e++) {
                    if (/[^\s]/.test(f[e]) && (c = navigator.mimeTypes[f[e]]) && (b = c.enabledPlugin) && (b.name || b.description)) {
                        return c
                    }
                }
            }
            return null
        }
    },
    findNavPlugin: function(g, d) {
        var a = this.isString(g) ? g : g.join(".*"), e = d === false ? "" : "\\d", b, c = new RegExp(a + ".*" + e + "|" + e + ".*" + a, "i"), f = navigator.plugins;
        for (b = 0; b < f.length; b++) {
            if (c.test(f[b].description) || c.test(f[b].name)) {
                return f[b]
            }
        }
        return null
    },
    AXO: window.ActiveXObject,
    getAXO: function(b, a) {
        var g = null, f, d = false, c = this;
        try {
            g = new c.AXO(b);
            d = true
        }
        catch (f) {
        }
        if (c.isDefined(a)) {
            delete g;
            return d
        }
        return g
    },
    convertFuncs: function(f) {
        var a, g, d, b = /^[\$][\$]/, c = {};
        for (a in f) {
            if (b.test(a)) {
                c[a] = 1
            }
        }
        for (a in c) {
            try {
                g = a.slice(2);
                if (g.length > 0 && !f[g]) {
                    f[g] = f[a](f)
                }
            }
            catch (d) {
            }
        }
    },
    initScript: function() {
        var $ = this, nav = navigator, userAgent = $.isString(nav.userAgent) ? nav.userAgent : "", vendor = $.isString(nav.vendor) ? nav.vendor : "", platform = $.isString(nav.platform) ? nav.platform : "";
        $.OS = (/win/i).test(platform) ? 1 : ((/mac/i).test(platform) ? 2 : ((/linux/i).test(platform) ? 3 : 4));
        $.convertFuncs($);
        $.isIE = /*@cc_on!@*/
        false;
        $.IEver = $.isIE && ((/MSIE\s*(\d\.?\d*)/i).exec(userAgent)) ? parseFloat(RegExp.$1, 10) : -1;
        $.ActiveXEnabled = false;
        if ($.isIE) {
            var x, progid = ["Msxml2.XMLHTTP", "Msxml2.DOMDocument", "Microsoft.XMLDOM", "ShockwaveFlash.ShockwaveFlash", "TDCCtl.TDCCtl", "Shell.UIHelper", "Scripting.Dictionary", "wmplayer.ocx"];
            for (x = 0; x < progid.length; x++) {
                if ($.getAXO(progid[x], 1)) {
                    $.ActiveXEnabled = true;
                    break
                }
            }
            $.head = $.isDefined(document.getElementsByTagName) ? document.getElementsByTagName("head")[0] : null
        }
        $.isGecko = !$.isIE && $.isString(navigator.product) && (/Gecko/i).test(navigator.product) && (/Gecko\s*\/\s*\d/i).test(userAgent);
        $.GeckoRV = $.isGecko ? $.formatNum((/rv\s*\:\s*([\.\,\d]+)/i).test(userAgent) ? RegExp.$1 : "0.9") : null;
        $.isSafari = !$.isIE && (/Safari\s*\/\s*\d/i).test(userAgent) && (/Apple/i).test(vendor);
        $.isChrome = !$.isIE && (/Chrome\s*\/\s*\d/i).test(userAgent);
        $.isOpera = !$.isIE && (/Opera\s*[\/]?\s*\d/i).test(userAgent);
        ;
        $.addWinEvent("load", $.handler($.runWLfuncs, $));

    },
    init: function(d, a) {
        var c = this, b;
        if (!c.isString(d)) {
            return -3
        }
        if (d.length == 1) {
            c.getVersionDelimiter = d;
            return -3
        }
        b = c[d.toLowerCase().replace(/\s/g, "")];
        if (!b || !b.getVersion) {
            return -3
        }
        c.plugin = b;
        if (!c.isDefined(b.installed) || a == true) {
            b.installed = b.version = b.version0 = b.getVersionDone = null;
            b.$ = c
        }
        c.garbage = false;
        if (c.isIE && !c.ActiveXEnabled) {
            if (b !== c.java) {
                return -2
            }
        }
        return 1
    },
    fPush: function(b, a) {
        var c = this;
        if (c.isArray(a) && (c.isFunc(b) || (c.isArray(b) && b.length > 0 && c.isFunc(b[0])))) {
            a[a.length] = b
        }
    },
    callArray: function(b) {
        var c = this, a;
        if (c.isArray(b)) {
            for (a = 0; a < b.length; a++) {
                if (b[a] === null) {
                    return
                }
                c.call(b[a]);
                b[a] = null
            }
        }
    },
    call: function(c) {
        var b = this, a = b.isArray(c) ? c.length : -1;
        if (a > 0 && b.isFunc(c[0])) {
            c[0](b, a > 1 ? c[1] : 0, a > 2 ? c[2] : 0, a > 3 ? c[3] : 0)
        }
        else {
            if (b.isFunc(c)) {
                c(b)
            }
        }
    },
    $$isMinVersion: function(a) {
        return function(h, g, d, c) {
            var e = a.init(h), f, b = -1;
            if (e < 0) {
                return e
            }
            f = a.plugin;
            g = a.formatNum(typeof g == "number" ? g.toString() : (a.isString(g) ? a.getNum(g) : "0"));
            if (!a.num(g)) {
                return -3
            }
            if (f.getVersionDone != 1) {
                f.getVersion(d, c);
                if (f.getVersionDone === null) {
                    f.getVersionDone = 1
                }
            }
            a.cleanup();
            if (f.installed !== null) {
                b = f.installed <= 0.5 ? f.installed : (f.version === null ? 0 : (a.compareNums(f.version, g, f) >= 0 ? 1 : -1))
            }
            return b
        }
    },
    getVersionDelimiter: ",",
    $$getVersion: function(a) {
        return function(g, d, c) {
            var e = a.init(g), f, b;
            if (e < 0) {
                return null
            }
            f = a.plugin;
            if (f.getVersionDone != 1) {
                f.getVersion(d, c);
                if (f.getVersionDone === null) {
                    f.getVersionDone = 1
                }
            }
            a.cleanup();
            b = (f.version || f.version0);
            return b ? b.replace(a.splitNumRegx, a.getVersionDelimiter) : b
        }
    },
    cleanup: function() {
    },
    addWinEvent: function(d, c) {
        var e = this, a = window, b;
        if (e.isFunc(c)) {
            if (a.addEventListener) {
                a.addEventListener(d, c, false)
            }
            else {
                if (a.attachEvent) {
                    a.attachEvent("on" + d, c)
                }
                else {
                    b = a["on" + d];
                    a["on" + d] = e.winHandler(c, b)
                }
            }
        }
    },
    winHandler: function(d, c) {
        return function() {
            d();
            if (typeof c == "function") {
                c()
            }
        }
    },
    WLfuncs: [0],
    runWLfuncs: function(a) {
        a.winLoaded = true;
        a.callArray(a.WLfuncs);
        if (a.onDoneEmptyDiv) {
            a.onDoneEmptyDiv()
        }
    },
    winLoaded: false,
    $$onWindowLoaded: function(a) {
        return function(b) {
            if (a.winLoaded) {
                a.call(b)
            }
            else {
                a.fPush(b, a.WLfuncs)
            }
        }
    },
    div: null,
    divWidth: 50,
    pluginSize: 1,
    emptyDiv: function() {
        var c = this, a, e, b, d = 0;
        if (c.div && c.div.childNodes) {
            for (a = c.div.childNodes.length - 1; a >= 0; a--) {
                b = c.div.childNodes[a];
                if (b && b.childNodes) {
                    if (d == 0) {
                        for (e = b.childNodes.length - 1; e >= 0; e--) {
                            b.removeChild(b.childNodes[e])
                        }
                        c.div.removeChild(b)
                    }
                    else {
                    }
                }
            }
        }
    },
    onDoneEmptyDiv: function() {
        var a = this;
        if (!a.winLoaded) {
            return
        }
        if (a.WLfuncs && a.WLfuncs.length > 0 && a.isFunc(a.WLfuncs[a.WLfuncs.length - 1])) {
            return
        }
        if (a.java) {
            if (a.java.OTF == 3) {
                return
            }
            if (a.java.funcs && a.java.funcs.length > 0 && a.isFunc(a.java.funcs[a.java.funcs.length - 1])) {
                return
            }
        }
        a.emptyDiv()
    },
    getObject: function(c, a) {
        var g, d = this, f = null, b = d.getContainer(c);
        try {
            if (b && b.firstChild) {
                f = b.firstChild
            }
            if (a && f) {
                f.focus()
            }
        }
        catch (g) {
        }
        return f
    },
    getContainer: function(a) {
        return (a && a[0] ? a[0] : null)
    },
    instantiate: function(i, c, f, a, j) {
        var l, m = document, h = this, q, p = m.createElement("span"), o, g, n = "/";
        var k = function(s, r) {
            var u = s.style, d, t;
            if (!u) {
                return
            }
            u.outline = "none";
            u.border = "none";
            u.padding = "0px";
            u.margin = "0px";
            u.visibility = "visible";
            if (h.isArray(r)) {
                for (d = 0; d < r.length; d = d + 2) {
                    try {
                        u[r[d]] = r[d + 1]
                    }
                    catch (t) {
                    }
                }
                return
            }
        }, b = function() {
            var s, t = "pd33993399", r = null, d = (m.getElementsByTagName("body")[0] || m.body);
            if (!d) {
                try {
                    m.write('<div id="' + t + '">o<' + n + "div>");
                    r = m.getElementById(t)
                }
                catch (s) {
                }
            }
            d = (m.getElementsByTagName("body")[0] || m.body);
            if (d) {
                if (d.firstChild && h.isDefined(d.insertBefore)) {
                    d.insertBefore(h.div, d.firstChild)
                }
                else {
                    d.appendChild(h.div)
                }
                if (r) {
                    d.removeChild(r)
                }
            }
            else {
            }
        };
        if (!h.isDefined(a)) {
            a = ""
        }
        if (h.isString(i) && (/[^\s]/).test(i)) {
            q = "<" + i + ' width="' + h.pluginSize + '" height="' + h.pluginSize + '" ';
            for (o = 0; o < c.length; o = o + 2) {
                if (/[^\s]/.test(c[o + 1])) {
                    q += c[o] + '="' + c[o + 1] + '" '
                }
            }
            q += ">";
            for (o = 0; o < f.length; o = o + 2) {
                if (/[^\s]/.test(f[o + 1])) {
                    q += '<param name="' + f[o] + '" value="' + f[o + 1] + '" />'
                }
            }
            q += a + "<" + n + i + ">"
        }
        else {
            q = a
        }
        if (!h.div) {
            h.div = m.createElement("div");
            g = m.getElementById("plugindetect");
            if (g) {
                h.div = g
            }
            else {
                h.div.id = "plugindetect";
                b()
            }
            k(h.div, ["width", h.divWidth + "px", "height", (h.pluginSize + 3) + "px", "fontSize", (h.pluginSize + 3) + "px", "lineHeight", (h.pluginSize + 3) + "px", "verticalAlign", "baseline", "display", "block"]);
            if (!g) {
                k(h.div, ["position", "absolute", "right", "0px", "top", "0px"])
            }
        }
        if (h.div && h.div.parentNode) {
            h.div.appendChild(p);
            k(p, ["fontSize", (h.pluginSize + 3) + "px", "lineHeight", (h.pluginSize + 3) + "px", "verticalAlign", "baseline", "display", "inline"]);
            ;
            try {
                if (p && p.parentNode) {
                    p.focus()
                }
            }
            catch (l) {
            }
            try {
                p.innerHTML = q
            }
            catch (l) {
            }
            if (p.childNodes.length == 1 && !(h.isGecko && h.compareNums(h.GeckoRV, "1,5,0,0") < 0)) {
                k(p.firstChild, ["display", "inline"])
            }
            return [p]
        }
        return [null]
    },
    flash: {
        mimeType: ["application/x-shockwave-flash", "application/futuresplash"],
        progID: "ShockwaveFlash.ShockwaveFlash",
        classID: "clsid:D27CDB6E-AE6D-11CF-96B8-444553540000",
        getVersion: function() {
            var c = function(i) {
                if (!i) {
                    return null
                }
                var e = /[\d][\d\,\.\s]*[rRdD]{0,1}[\d\,]*/.exec(i);
                return e ? e[0].replace(/[rRdD\.]/g, ",").replace(/\s/g, "") : null
            };
            var j, g = this.$, h, f, b = null, a = null, d = null;
            if (!g.isIE) {
                j = g.findNavPlugin("Flash");
                if (j && j.description && g.hasMimeType(this.mimeType)) {
                    b = c(j.description)
                }
            }
            else {
                for (f = 15; f > 2; f--) {
                    a = g.getAXO(this.progID + "." + f);
                    if (a) {
                        d = f.toString();
                        break
                    }
                }
                if (d == "6") {
                    try {
                        a.AllowScriptAccess = "always"
                    }
                    catch (h) {
                        return "6,0,21,0"
                    }
                }
                try {
                    b = c(a.GetVariable("$version"))
                }
                catch (h) {
                }
                if (!b && d) {
                    b = d
                }
            }
            this.installed = b ? 1 : -1;
            this.version = g.formatNum(b);
            return true
        }
    },
    windowsmediaplayer: {
        mimeType: ["application/x-mplayer2", "application/asx"],
        progID: "wmplayer.ocx",
        classID: "clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6",
        getVersion: function() {
            var a = null, e = this.$, b = null;
            this.installed = -1;
            if (!e.isIE) {
                if (e.hasMimeType(this.mimeType)) {
                    if (e.findNavPlugin(["Windows", "Media", "(Plug-in|Plugin)"], false) || e.findNavPlugin(["Flip4Mac", "Windows", "Media"], false)) {
                        this.installed = 0
                    }
                    var d = e.isGecko && e.compareNums(e.GeckoRV, e.formatNum("1.8")) < 0;
                    if (!d && e.findNavPlugin(["Windows", "Media", "Firefox Plugin"], false)) {
                        var c = e.instantiate("object", ["type", this.mimeType[0]], [], "", this), f = e.getObject(c);
                        if (f) {
                            a = f.versionInfo
                        }
                    }
                }
            }
            else {
                b = e.getAXO(this.progID);
                if (b) {
                    a = b.versionInfo
                }
            }
            if (a) {
                this.installed = 1
            }
            this.version = e.formatNum(a)
        }
    },
    silverlight: {
        mimeType: "application/x-silverlight",
        progID: "AgControl.AgControl",
        digits: [9, 20, 9, 12, 31],
        getVersion: function() {
            var e = this.$, j = document, i = null, c = null, h = false, b = [1, 0, 1, 1, 1], r = [1, 0, 1, 1, 1], k = function(d) {
                return (d < 10 ? "0" : "") + d.toString()
            }, n = function(s, d, u, v, t) {
                return (s + "." + d + "." + u + k(v) + k(t) + ".0")
            }, o = function(d, s) {
                return q((d == 0 ? s : r[0]), (d == 1 ? s : r[1]), (d == 2 ? s : r[2]), (d == 3 ? s : r[3]), (d == 4 ? s : r[4]))
            }, q = function(t, s, w, v, u) {
                var u;
                try {
                    return c.IsVersionSupported(n(t, s, w, v, u))
                }
                catch (u) {
                }
                return false
            };
            if (!e.isIE) {
                var a = [null, null], f = e.findNavPlugin("Silverlight Plug-in", false), g = e.isGecko && e.compareNums(e.GeckoRV, e.formatNum("1.6")) <= 0;
                if (f && e.hasMimeType(this.mimeType)) {
                    i = e.formatNum(f.description);
                    if (i) {
                        r = i.split(e.splitNumRegx);
                        if (parseInt(r[2], 10) >= 30226 && parseInt(r[0], 10) < 2) {
                            r[0] = "2"
                        }
                        i = r.join(",")
                    }
                    if (e.isGecko && !g) {
                        h = true
                    }
                    if (!h && !g && i) {
                        a = e.instantiate("object", ["type", this.mimeType], [], "", this);
                        c = e.getObject(a);
                        if (c) {
                            if (q(b[0], b[1], b[2], b[3], b[4])) {
                                h = true
                            }
                            if (!h) {
                                c.data = "data:" + this.mimeType + ",";
                                if (q(b[0], b[1], b[2], b[3], b[4])) {
                                    h = true
                                }
                            }
                        }
                    }
                }
            }
            else {
                c = e.getAXO(this.progID);
                var m, l, p;
                if (c && q(b[0], b[1], b[2], b[3], b[4])) {
                    for (m = 0; m < this.digits.length; m++) {
                        p = r[m];
                        for (l = p + (m == 0 ? 0 : 1); l <= this.digits[m]; l++) {
                            if (o(m, l)) {
                                h = true;
                                r[m] = l
                            }
                            else {
                                break
                            }
                        }
                        if (!h) {
                            break
                        }
                    }
                    if (h) {
                        i = n(r[0], r[1], r[2], r[3], r[4])
                    }
                }
            }
            this.installed = h && i ? 1 : (i ? -0.2 : -1);
            this.version = e.formatNum(i)
        }
    },
    zz: 0
};

PluginDetect.initScript();
/************************************************************************/
/*									END									*/
/************************************************************************/
var mediaStock = {
    uploadPath: "",

    getImagePath: function(MediaStockImageID, MediaStockImageTypeID, MediaStockImageExt) {
        
        if (MediaStockImageID == "" || MediaStockImageID == null || MediaStockImageID == 0 || typeof (MediaStockImageID) == "undefined")
            return "";
        if (MediaStockImageTypeID != "" && MediaStockImageTypeID != null && MediaStockImageTypeID != 0) {
            return mediaStock.uploadPath + "/upload/mediastock/img/" + MediaStockImageTypeID + "/" + parseInt(MediaStockImageID / 1000000) + "/" + parseInt((MediaStockImageID % 1000000) / 1000) + "/" + MediaStockImageID + "." + MediaStockImageExt;
        }
        return mediaStock.uploadPath + "/upload/mediastock/NOREPLICATION/img/" + parseInt(MediaStockImageID / 1000000) + "/" + parseInt((MediaStockImageID % 1000000) / 1000) + "/" + MediaStockImageID + "_THUMBNAIL." + MediaStockImageExt;
    },

    getImageType: function(fileExtensionID) {
        fileExtensionID = parseInt(fileExtensionID);
        switch (fileExtensionID) {
            case 1:
                return "jpg";
            case 2:
                return "gif";
            case 3:
                return "jpeg";
            case 5:
            case 445:
                return "bmp";
            case 125:
                return "png";

            default:
                return "jpg";
        }
    }
};
