$.ajax({
type: "GET",
url: '/application/views/itpnet/js/jquery.plugins.min.js',
dataType: "script",
cache : true,
success:function(){ $(document).ready(function() {


	$(document).ajaxStart(function(){$.systemBusy()});
	$(document).ajaxComplete(function(){$.notBusy()});

	/* ALL SET, INITIALIZE */

	if(!$.cookies.get('itp.version')) {
		//alert('No version cookie found, writing cookie. Version: '+ ITP.version)
		$.cookies.set('itp.version', ITP.version, {hoursToLive: 360})
	} 
		/*$(document).each(function(){
				if(ITP.version != $.cookies.get('itp.version','version')){
					//alert('Versions missmatch! (cookie version: '+$.cookies.get('itp.version','version') +' | document version: ' + ITP.version+ ') Forcing reload...')				
					$('head > link[type=text/css]').load('/application/views/itpnet/css/base.css', function(){
						//alert('CSS reloaded.')
						$.cookies.set('itp.version', ITP.version)
						//alert('Force reload complete, version updated...')
					})
				} else {
					//alert('Versions match! (cookie: '+$.cookies.get('itp.version','version') +' | document: ' + ITP.version+') Good to go!')
				}
		});*/

		$('#mainlogout').each(function(){
			
			var sure = 'Are you sure? Do you want to log out?'
			var stay = 'Stay logged in'
			var out = 'Log out!'
			var host= '';
			if(lang === 'arabic') {			
				sure = '&#1607;&#1604; &#1571;&#1606;&#1578; &#1605;&#1578;&#1571;&#1603;&#1583;&#1567; &#1607;&#1604; &#1578;&#1585;&#1610;&#1583; &#1578;&#1587;&#1580;&#1610;&#1604; &#1575;&#1604;&#1582;&#1585;&#1608;&#1580;'
				stay = '&#1575;&#1604;&#1576;&#1602;&#1575;&#1569; &#1605;&#1578;&#1589;&#1604;&#1575;'
				out = '&#1578;&#1587;&#1580;&#1610;&#1604; &#1575;&#1604;&#1582;&#1585;&#1608;&#1580;'	
				host = '/arabic/'		
			}			
			
			var link = $(this).attr('href');
			$(this).attr('href','#:here');
			$(this).click(function(){
				$.questionBox({msg:sure,
					truebtn:stay,
					falsebtn:out,
					returnFalse:function(){
						$('#shell').fadeTo('slow',0.3);
						$.ajax({url:host+'/userlogin/logout',success:function(){
								window.location = host+'/userlogin/logout';
							}});
					}
				});
			});
		});
		
		$('#debug_form').each(function(){
			var initialLeft = $(this).css('left')
			$(this).mouseenter(function(){
				$(this).stop().animate({left:0});
			});
			$(this).mouseleave(function(){
				$(this).stop().animate({left:initialLeft});
			});
		});
		
		//article picture zoom in - zoom out
		$('.article_picture').each(function(){
			var state = true
			var zoomin, zoomout
			for(k in $.browser){
				if(k === 'mozilla' && $.browser[k]){zoomin='-moz-zoom-in';zoomout='-moz-zoom-out'}
				if((k==='msie' && $.browser[k]) || (k==='opera' && $.browser[k])){zoomin='url("/pictures/furniture/zoomin.cur")';zoomout='url("/pictures/furniture/zoomout.cur")'}
				if(k === 'safari' && $.browser[k]){zoomin='-webkit-zoom-in';zoomout='-webkit-zoom-out'}
			}
			var that = $(this)
			var credits = $('.article_credits')
			var inW = credits.find('.article_source').width()
			that.css({'cursor':zoomin,'background':'#fff','border-color':'#ccc'})
			var pr = {p:that.css('padding-left'),ml:that.css('margin-left'),mr:that.css('margin-right')}
			var floater = that.css('float')
			credits.css({'width':inW,'float':'left'})
			that.click(function(l){
				if ($(l.target).attr('href') === undefined){
					if(state){
						state = false
						credits.stop().slideUp('fast',function(){credits.slideDown('fast').css({'clear':'both','float':'none','width':''})})
						that.stop().animate({width:'100%',borderTopColor:'#fff',borderRightColor:'#fff',borderBottomColor:'#fff',borderLeftColor:'#fff',paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,marginLeft:0,marginRight:0},300)
						that.css({'cursor':zoomout,'clear':'both'})
					} else {
						state = true
						credits.stop().slideUp('fast',function(){credits.slideDown('fast').css({'clear':'','float':'left','width':inW})})
						that.stop().animate({width:'50%',borderTopColor:'#ccc',borderRightColor:'#ccc',borderBottomColor:'#ccc',borderLeftColor:'#ccc',paddingLeft:pr.p,paddingRight:pr.p,paddingTop:pr.p,paddingBottom:pr.p,marginLeft:pr.ml,marginRight:pr.mr},300)
						that.css({'cursor':zoomin,'float':floater})
					}
				} else {
					return
				}
			})
		})

		$('#head').each(function(){
			var but = $(this).find('.discuss > a');
			var link = but.attr('href')
			but.attr('href','#:here')
			var formy = $('.comment_form')
			var s = {h:formy.css({'position':'absolute','visibility':'hidden','display':'block'}).height(),pt:formy.css('padding-top'),pb:formy.css('padding-bottom'),mt:formy.css('margin-top'),mb:formy.css('margin-bottom')}
			
			var props = {height:s.h,paddingTop:s.pt,paddingBottom:s.pb,marginTop:s.mt,marginBottom:s.mb,opacity:1}
			formy.css({'display':'none','position':'static','visibility':'visible',opacity:0,'height':0,'padding-top':0,'padding-bottom':0,'margin-top':0,'margin-bottom':0})
			if(formy.length !== 0){
				but.click(function(){
					formy.animate(props,'slow',function(){
						but.attr('href',link)
					})
					but.unbind('click')
				})
				
			}
		})
		

		$('#article .alsoin').each(function(k){
			var $that = $(this)
			var lis = $that.find('li')
			var track = 0
			$(document).bind('scroll.blinker'+k, function(){
				if($(document).scrollTop() > (parseInt(($that.position().top+$that.height())-($(window).height())))){
					blinker(track)
					$(document).unbind('scroll.blinker'+k);
				}
			});
			function blinker(tr){
				$(lis[tr]).fadeTo('normal',0,function(){				
					$(this).fadeTo('fast',1)
					if(track < lis.length-1){
						track++
						blinker(track)}
				})
				
			}
		})
		//text switcher for input elements
		$("input:text[value]").each(function(){
			$(this).attr('title', $(this).attr('value'))
			$(this).focus(function(){
				if ($(this).attr('value') === $(this).attr('title')){
					$(this).attr('value','');}
			});			
			$(this).blur(function(){
				if ($(this).attr('value') === '') {
					$(this).attr('value',$(this).attr('title'));
				}
			})
		})
		//text switcher for textarea elements
		$("textarea").each(function(){
			if ($(this).text() !=="") {
				$(this).addClass('unfocused')
				$(this).attr('title', $(this).text())
				$(this).focus(function(){
					if ($(this).attr('value') === $(this).attr('title')){
						$(this).text("");
						$(this).attr('value', '')
					}
				});			
				$(this).blur(function(){
					if ($(this).attr('value') === '') {
						$(this).attr('value', $(this).attr('title'));
					}		
				})
			} else {return}
		})
		
		//change reset buttons with image buttons and attach question box
		$("button:reset, input:reset").each(function(){
		
		var cancellan = "Cancel";
		var truelan = "Clear form";
		var doyoureally = "Do you really want to clear form?";
		
		if(lang === 'arabic') {			
				cancellan = " &#1573;&#1604;&#1594;&#1575;&#1569; &#1575;&#1604;&#1571;&#1605;&#1585;";
				truelan = "&#1581;&#1584;&#1601; &#1575;&#1604;&#1605;&#1588;&#1575;&#1585;&#1603;&#1577;";
				doyoureally = "&#1607;&#1604; &#1571;&#1606;&#1578; &#1605;&#1578;&#1571;&#1603;&#1583; &#1571;&#1606;&#1603; &#1578;&#1585;&#1610;&#1583; &#1581;&#1584;&#1601; &#1575;&#1604;&#1605;&#1588;&#1575;&#1585;&#1603;&#1577;&#1567;"
		}	
		
		
			$(this).parent().append('<button type="button" class="clear_replace img clear">Clear</button>')
			$(".clear_replace").each(function(){
				$(this).removeClass('clear_replace')
				$(this).click(function(){
					var $current = $(this).parents('form')
					var $that = $(this)
					$(this).fadeTo('fast',0.5).attr('disabled','disabled').css({'cursor':'auto'})
					$.questionBox({
						msg: doyoureally,
						truebtn: truelan,
						returnTrue:function() {
							$current[0].reset()
							$current.find('.set_rating').removeClass('active')
							$that.fadeTo('fast',1).attr('disabled','').css({'cursor':'pointer'})
						},
						falsebtn: cancellan,
						returnFalse:function(){
							$that.fadeTo('fast',1).attr('disabled','').css({'cursor':'pointer'})
						}
					})
				})
			})
			$(this).remove()
		})
		//change submit buttons with image buttons and attach question box
		$("button:submit, input.submit").each(function(){
			$(this).click(function(){
				$(this).fadeTo('fast',0.5).attr('disabled','disabled').css({'cursor':'auto'})		
			})
		})
		//focus highlight class swapper for input/textbox elements
		$("input:text, textarea").each(
		function(){
			$(this).removeClass('focused'); $(this).addClass('unfocused'); 
			$(this).focus(function(){
				$(this).removeClass('unfocused'); $(this).addClass('focused'); 
			})
			$(this).blur(
			function(){
				$(this).removeClass('focused'); $(this).addClass('unfocused'); 
			})
		})
		/*----------------------------------------------------------------------------------------------------*/
		
		
		$(".global_tabs:first").each(function(){
			$(".global_tabs").tabs({fx:{opacity:'toggle'}},'fast');
		})
		
		//turn radio buttons into stars when needed (by classname)
		$(".radio2star").each(function(){
			var $root = $(this)
			$(this).hover(
			function(){
				$(this).addClass('hovered')
			},
			function(){$(this).removeClass('hovered')
			});
			$(this).find("input").each(
			function(k){
				$(this).hide();
				$(this).parent().append('<span class="set_rating"></span>')
			})	
			$(this).find('.set_rating').each(
			function(k){
				$(this).hover(
				function(){
					for(var z=0; z<=k; z++) {
						$root.find('.set_rating:eq('+z+')').addClass('hovered')
					};
					$(this).addClass('hovered')
				},
				function(){
					$(this).parent().find(".set_rating").removeClass('hovered')
				}
				)
				$(this).mousedown(
				function(){
					
					$(this).parent().find(".set_rating").removeClass('active');
					for(var z=0; z<=k; z++) {
						$root.find(".set_rating:eq("+z+")").addClass('active')
						$root.find(".set_rating:eq("+z+")").addClass('clicked')
					}
					$(this).parent().find("input:radio:eq("+k+")").each(
					function(){
						$(this).attr('checked','checked')
					})
				}).mouseup(
				function(){$root.find("span").removeClass('clicked')}
				)
			})
			// reset stars if reset is clicked
			$(this).parents('form').find('*:reset').click(function(){
				$(this).parents('form').find('.set_rating').removeClass('active')
			})
		})
		/*----------------------------------------------------------------------------------------------------*/


		
		
		/*----------------------------------------------------------------------------------------------------*/
		//PHOTO SLIDE SHOW 
		$(".slideshow_nav").each(function(){
			var stay = 15
			var $that = $(this)
			var link = $(this).find('.next').attr('href')
			var total = 25*stay
			var count = 0
			var slideShow,timer
			var switcher = $that.find(".slideswitch")
			if(!$.cookies.get('itp.version')){
				switcher.remove();
			} else {
				function slideShow(){
					swi = 0
					nextpage = function () {
						count++
						var perc = ((count/total)*100)
						$that.find(".progress_bar").css({'width':perc+'%'}).find('span')
						if(count === total) {
							clearInterval(timer)
							$.cookies.set('itp.scroll', $(window).scrollTop(), {hoursToLive: 360})
							window.location=link
						}
					}
					timer = setInterval("nextpage()",40)
					$(window).load(function(){
						nextpage();
					})
				}
				if (!$.cookies.get('slideshowreminder')){
					switcher.find('dfn').html('<img src="/pictures/furniture/slideshow_pause.png" title="Stop auto slideshow"/>')
					$(".time_bar").show()
					slideShow();
				} else if ($.cookies.get('slideshowreminder')){
					switcher.find('dfn').html('<img src="/pictures/furniture/slideshow_play.png" title="Start auto slideshow"/>')
				}
				switcher.bind('click',function(){
					if (!$.cookies.get('slideshowreminder')){
						$.cookies.set('slideshowreminder', 'created')
						clearInterval(timer)
						switcher.find('dfn').html('<img src="/pictures/furniture/slideshow_play.png" title="Start auto slideshow"/>')
						$(".time_bar").fadeOut()
					}
					else if ($.cookies.get('slideshowreminder')){
						$.cookies.del('slideshowreminder')
						slideShow();
						switcher.find('dfn').html('<img src="/pictures/furniture/slideshow_pause.png" title="Stop auto slideshow"/>')
						$(".time_bar").fadeIn()

					}
				})
			}
		})
		$(".slideshow_nav").each(function(){
			if($.cookies.get('itp.scroll')){
				$('html,body').animate({scrollTop:$.cookies.get('itp.scroll')}, 500);
			}
			$(this).mousedown(function(){
				$.cookies.set('itp.scroll', $(window).scrollTop(), {hoursToLive: 360})
			})
		})
		
		

		
		/* FONT ADJUSTER */
		$("#article #article_header").css({'font-size':$("body").css('font-size')})
		var	fontResize = parseInt($("#article_header").css('font-size'))
		if($.cookies.get('SettedfontSize'))	{
			fontResize = $.cookies.get('SettedfontSize')
			fontResizer();
		}
		$("#incfont").mousedown(function(){
			if (fontResize < 18){
				fontResize++
				fontResizer()
				$.cookies.set('SettedfontSize', fontResize)
			}
		})
		$("#decfont").mousedown(function(){
			if (fontResize > 10){
				fontResize--
				fontResizer()
				$.cookies.set('SettedfontSize', fontResize)
			}
		})
		
		function fontResizer() {
			$(".article_module").css({'font-size':fontResize+'px'})
			$(".comments_module").css({'font-size':fontResize+'px'})
			$("#article_header").css({'font-size':fontResize+'px'})
			$(".photos_picture").css({'font-size':fontResize+'px'})
		}
		
		// style adjuster
		$('#fontstyle').toggle(
		function(){
			$(".article_module p").addClass('tsans')
			$("#article_header p").addClass('tsans')
			$(this).addClass('tsans')
			$(this).text('Serif')
		},
		function(){
			$(".article_module p").removeClass('tsans')
			$("#article_header p").removeClass('tsans')
			$(this).removeClass('tsans')
			$(this).text('Sans serif')
		})
		/*----------------------------------------------------------------------------------------------------*/
		

		function attachKeyClose(element, func){
			$(document).keyup(function(e) { 
				if(e.keyCode === 13 || e.keyCode === 32) { 
					element.each(func)
					$(document).unbind('keyup')
				} 
			}); 
		}

		$(".accord > dl").each(function(){
			var maxHeight = $(this).find('dd.opened').css('height')
			$(this).find('dt').each(function(){
				var dds = $(this).parent().find('dd')
				$(this).mouseover(function(){
					var $that = $(this)
					dds.each(function(){
						if($(this).css('height') != 0){	
							$(this).stop().animate({height:0},400)
						}
					})
					$(this).next().stop().animate({height:maxHeight},400,function(){dds.stop().animate({height:0},400);$(this).stop()})
				})
			})
		})
		
		/*----------------------------------------------------------------------------------------------------*/
		
		function waitBox(message){
			if($('.waitbox').length === 0){
				if (message) {msg=message} else {msg="Please wait"};
				$("body").prepend('<div class="shader"></div><div class="waitbox"><div class="shade_bg"></div><div class="contain"><img  src="/pictures/furniture/waiter.gif"/><div class="msg">'+msg+'</div></div></div>');
				var ust = (($(window).height()/2) + $(window).scrollTop())-($(".waitbox").outerHeight()/2)
				var sag = $(window).width()/2-($(".waitbox").outerWidth()/2)
				$(".shader").css({'height':$('body').height()})
				$(".waitbox").fadeIn('fast').css({'top':ust, 'left':sag})		
				$(window).resize(function(){rePos()})
				$(window).scroll(function(){rePos()})
				var rePos = function() {
					ust = (($(window).height()/2) + $(window).scrollTop())-($(".waitbox").outerHeight()/2)
					sag = $(window).width()/2-($(".waitbox").outerWidth()/2)
					$(".waitbox").animate({top:ust},{queue:false},100).animate({left:sag},{queue:false},100,function(){$('.waitbox').stop()})
				}
			} else {
				$(".waitbox").stop(true,true).fadeOut('fast', function(){$(".waitbox").remove();$(window).unbind('resize');$(window).unbind('scroll')});
				$(".shader").fadeOut('normal');
			}
		}
		
		/* global ROTATOR */
		$("#rev_rot, #news_rot, .features_module").each(function(){
			var slidedelay = 10 // default slidedelay by seconds
			var out // setTimeout var
			var indicator = $(this).find('.indicate') //page indicator area
			var $that = $(this).find('ul') //find main UL
			var lis  = $that.children("li").length;			//find numbers of LIs
			var slideWidth = $that.width() // find what UL's width should be
			var index = 0 //ourt index for pages
			var liWidth  = $that.find('li').width() + parseInt($that.find('li').css('margin-left')) + parseInt($that.find('li').css('margin-right')); // find LIs width
			var imgs = $that.find('img')
			var imgWidth = $that.find('img:first').width()
			var imgHeight = $that.find('img:first').height()
			$that.css({'width':(lis*liWidth)}) // setUL's width
			var slideIndex = parseInt((lis*liWidth)/slideWidth) // find total pages
			var liRatio = Math.round($(this).width()/liWidth)
			for (z=0;z< liRatio;z++){
				$that.find("li:eq("+(z+(liRatio*index))+")").addClass("visible")
			}
			indicator.text((index+1)+"/"+slideIndex) // set indicator text
			out = setTimeout (auto,slidedelay*1000); //init auto slide
			function forward(){
				index++
				$that.children("li").removeClass("visible")
				for (z=0;z<liRatio;z++){
					$that.children("li:eq("+(z+(liRatio*index))+")").addClass("visible")
				}
				if (index < slideIndex){
					$that.stop().animate({marginLeft:-(index*slideWidth)},'slow')
					$that.find("li.visible > div > img").stop().css({'width':imgWidth*2,'height':imgHeight*2,'margin-top':-(imgHeight/2),'margin-right':0}).animate({width:imgWidth, height:imgHeight,marginTop:0},'slow')
				} else if (index === slideIndex) {
					$that.stop().animate({marginLeft:0},'slow')
					index = 0
				}
				indicator.text((index+1)+"/"+slideIndex)
			}
			function backward(){
				index--
				$that.find("li").removeClass("visible")
				for (z=0;z<liRatio;z++){
					$that.find("li:eq("+(z+(liRatio*index))+")").addClass("visible")
				}
				if (index >= 0){
					$that.stop().animate({marginLeft:-(index*slideWidth)},'slow')
					$that.find("li.visible > div > img").stop().css({'width':imgWidth*2,'height':imgHeight*2,'margin-top':-(imgHeight/2),'margin-right':0}).animate({width:imgWidth, height:imgHeight,marginTop:0},'slow')
				} else if (index < 0) {
					$that.stop().animate({marginLeft:-((slideIndex-1)*slideWidth)},'slow')
					index = slideIndex-1
				}
				indicator.text((index+1)+"/"+slideIndex)
				$that.find("li").removeClass('visible')
				for (z=0;z< liRatio;z++){
					$that.find("li:eq("+(z+(liRatio*index))+")").addClass("visible")
				}
			}
			function auto() {
				forward();
				out = setTimeout(auto,slidedelay*1000)
			}
			$(this).find(".forbut").click(function(){forward();clearTimeout(out)})
			$(this).find(".bacbut").click(function(){backward();clearTimeout(out)})
		})

		/*----------------------------------------------------------------------------------------------------*/
		
		$(".big_calendar tr").each(function(k){
			var $that = $(this).parents('.big_calendar')
			$(this).find("td").each(function(l){
				$(this).hover(function(){
					$that.find("thead td:eq("+l+")").css({"background-color":"#9EB8CF","color":"#fff"})
				}, function(){
					$that.find("thead td:eq("+l+")").css({"background-color":"#fff","color":"#333"})
				})
			})
		})
		
		/* MULTIMEDIA SLIDER COMPONENT */
		$(".multimedia_show").each(
		function(){
			$(this).css({width:$(this).width(),'overflow':'hidden'})
			var pic = $(this).find(".photos")
			var tex = $(this).find(".headlines > .fi")
			var thu = $(this).find(".thumbs")
			var mle, mto
			thu.find("a").each(
			function(k){
				$(this).find("img").fadeTo('fast',0.7)
				$(this).hover(
				function(){
					$(this).find("img").fadeTo('fast',1)
					tex.stop()
					pic.stop()
					mle = -(483*k);
					mto = -(58*k);
					pic.animate({marginLeft:mle})
					tex.animate({marginTop:mto})
				}, 
				function(){
					$(this).find("img").fadeTo('fast',0.7)
				})
			})
		})
		/*----------------------------------------------------------------------------------------------------*/
		
	
		/*----------------------------------------------------------------------------------------------------*/
		
		$('#navigate_article').each(function(){
			$(this).find('a').each(function(){
				var dfn = $(this).find('dfn')
				$(this).mouseenter(function(){
					$(dfn).show()
				})
				$(this).mouseleave(function(){
					$(dfn).hide()
				})
			})
		})
		/* LITTLE INFO ICON */
		$(".info_icon > img").each(function(){
			$(this).click(
			function(){
				title = $(this).attr('title');
				$(this).attr('title','')
				var ust = $(this).position().top - ($(this).height()/2)-1
				var sol = $(this).position().left + ($(this).width())+4
				$(this).parent().find("dfn").css({'top':ust,'left':sol,opacity:0}).show().fadeTo("normal", 0.9)
				$(this).css({'cursor':'default'})

			})
			$(this).mouseout(function(){
				$(this).attr('title',title)
				$(this).parent().find("dfn").fadeOut('normal')
				$(this).css({'cursor':''})
			})
		})
		
		/*----------------------------------------------------------------------------------------------------*/
		
		/* FORM ELEMENTS FORM TIP  */
		$(".add_form_tip").find('*:input').each(
		function(){		
			$(this).focus(
			function(){
				var ust = $(this).position().top
				var sol = $(this).position().left + ($(this).width())+10
				$(this).parent().find(".form_tip").css({'top':ust, 'left':sol}).show('fast')
			})
			$(this).blur(function(){		
				$(this).parent().find("dfn.form_tip").hide('fast')
			})
		})
		/*----------------------------------------------------------------------------------------------------*/
		$('#comparelist').each(function(){
			$(this).append("<h3>You're comparing</h3>")
			$(this).append('<ul></ul>')
			var a = $('<a href="#:here"  style="display:none; float:none;" class="orange_but" >' +
			'<span style="text-align:center">Compare Now</span></a>');
			
			a.bind('click', function() {
				//Build the url 
				var url = [];
				$('input:checkbox[name=cmp]:checked').each(function() { url.push('cmp[]='+this.value) });
				window.open('/popup/module/180/?' + url.join('&'), 'cmpw', 'width=800,height=600');
			}
			);

			$(this).append(a);
		});
		$('.compare_chk').each(function(){
			var list = $('#comparelist').find('ul:first')
			var title = $(this).parents('.review_blocks').find('h4').text()
			var pro_id = $(this).attr('value')
			var that = $(this)
			$(this).bind('click.trig',function(){
				if($(this).attr('checked') === true) {
					list.append('<li style="display:none;" id="pro_'+pro_id+'">'+title+'</li>')
					$('#pro_'+pro_id).slideDown('fast',function(){buttonCh();})
					$('#pro_'+pro_id).bind('click.sub', function(){
						$('#product_'+pro_id+':checkbox').attr('checked', false);
						list.find('#pro_'+pro_id).slideUp('fast',function(){$(this).remove();buttonCh();})
						$(this).unbind('click')
					})
				} else if ($(this).attr('checked') === false) {
					list.find('#pro_'+pro_id).slideUp('fast',function(){$(this).remove();buttonCh();})
				}
			})
			function buttonCh() {
				if ($('#comparelist ul li').length >= 2) {
					$('#comparelist .orange_but').slideDown('fast')
				} else if ($('#comparelist ul li').length === 1) {
					$('#comparelist .orange_but').slideUp('fast')
					$('#comparelist:hidden').fadeIn('normal')
				} else if ($('#comparelist ul li').length < 1){
					$('#comparelist').fadeOut('normal')
				}
			}
		})
		$('.comparison table').each(function(){
			$(this).find('tr td').hover(
			function() {
				$(this).css({'background-color':'#f3f3f3'})
			},
			function() {
				$(this).css({'background-color':''})
			}
			)
		})
		//help tip */
	
		$('.addtip').each(function(){
			var helpTip = {title:$(this).attr('title')}
			var that = $(this)
			var mt
			that.unbind('mouseenter.helptip').bind('mouseenter.helptip',
			function(){
				that.attr('title', '')
				$('body').append("<div id='mousetooltip' class='helptip'><span>"+helpTip.title+"</span><div>")
				mt = $('#mousetooltip').show()
				if (mt.outerWidth() >= 250) {
					mt.css({width:250})
				} else {
					mt.css({width:mt.outerWidth()})
				}
				var pr = {docW:$(document).width(),tipW:mt.outerWidth(),tipWn:mt.outerWidth()-20,tipWp:mt.outerWidth()+10}
				$(document).bind('mousemove.helptip', function(e){
					if(e.pageX+pr.tipW > pr.docW){
						mt.css({left:(e.pageX+pr.docW)-(e.pageX+pr.tipWn)})
					}
					else if(e.pageX+pr.tipWp < pr.docW){
						mt.css({left:e.pageX-10})
					}
					mt.css({top:e.pageY+20})
				})
			});
			that.unbind('mouseleave').bind('mouseleave',function(){
				that.attr('title', helpTip.title);
				mt.remove()
				$(document).unbind('mousemove.helptip')
			})
			
		})
		
		$('.inline_calendar').each(function(){
			$(this).datepicker();
		})
		
		
		$('#pickdate').focus(function(){
			var $that = $(this)
			var dates = {sep:' to '};
			$(this).attr('value',dates.start+dates.sep+dates.end)
			$("#from").datepicker({altField:'#datefrom',maxDate:new Date(), onSelect:function(k){
					dates.start = k
					$that.attr('value', dates.start+dates.sep+dates.end)
					var d = $('#datefrom').attr('value').split('-')
					var otherdate = $("#to").datepicker('getDate')
					$("#to").datepicker('option', 'minDate', new Date(d[0], d[1]-1, d[2]));
					$("#to").datepicker('setDate',otherdate)
				}}).slideDown('normal');
			$("#to").datepicker({altField:'#dateto',minDate:new Date(), onSelect:function(k){
					dates.end = k
					$that.attr('value', dates.start+dates.sep+dates.end)
					var d = $('#dateto').attr('value').split('-')
					var otherdate = $("#from").datepicker('getDate')
					$("#from").datepicker('option', 'maxDate', new Date(d[0], d[1]-1, d[2]));
					$("#from").datepicker('setDate',otherdate)
				}}).slideDown('normal');
			$(".goDate").each(function(){
				var span = $(this).attr('title');
				$(this).attr('title',"")
				$(this).click(function(){
					if (parseInt(span) > 0){
						$("#from").datepicker('setDate')
						$("#to").datepicker('setDate',span)
					} else if (parseInt(span) < 0){
						$("#from").datepicker('setDate',span)
						$("#to").datepicker('setDate')
					} else if (parseInt(span) === 0){
						$("#from").datepicker('setDate')
						$("#to").datepicker('setDate')
					}
					$that.attr('value', dates.start+dates.sep+dates.end)
				})
			})
			
			$(".holder").slideDown('fast')
			$(".holder").css({'left':220})	
			$("#from").css({left:$(".holder").position().left,'top':$(".holder").position().top})
			$("#to").css({'left':$("#from").position().left+$("#from").width()+9,'top':$(".holder").position().top})
			$('.closeDate').click(function(){
				$("#from").slideUp('normal')
				$("#to").slideUp('normal')
				$(".holder").slideUp('slow')
			})
		})
		

	$("#brand_menu > li:first-child").css({'border-left':'none'})
	$("#brand_menu > li:first").css({'border-right':'none'})
	$(".in_article_col:first").each(function(){$(this).find('ul > li:last-child').css('background','none')})
	
	$("#main_nav > ul > li").find("div").each(function(z){
		$(this).find('div.topic').each(function(k){
			if (k===0 && $(this).prev().attr('class')!=='section') {
				$(this).css({'background':'none'})	
				}
			})
	})
	
	/* REVIEW HOME GROUP TESTS MARGIN FIX */
	$(".reviews_home.grouptest dd:last-child").css("margin","0px")	
	
	/* BUTTON TAG HOVERS */
	$("button").hover(function(){$(this).addClass('hovered')},function(){$(this).removeClass('hovered')});
	/* PUTS MINI NUMBERS FOR MOST POPULAR LIST  */
	$("#most_popular_module").find("ol").each(function(){
			$(this).find("a").each(function(k) {
				$(this).css({'background-position' : -(k*400)+'px 3px'})
			})
		}
	)
	/*EXPLORE MODULE LI BORDER REMOVAL*/
	$(".explore_mod ul > li").find("ul").each(function(){
		$(this).find("li:first").each(function(k){$(this).css({'border-left':'none'})})
		$(this).find("li:last").each(function(k){$(this).css({'border-right':'none'})})
		});

	
	
		/* HEDLINE SWITCHER */
	$("#sectionheadline").each(function(){
		if (lang !== 'arabic'){
			var that = $(this)
			var header = $('#sectionheadline').text().replace(/&/,'%26')
			var so = new SWFObject("/application/views/itpnet/flash/headline.swf", "mymovie", "646", "40", "8", "#ffffff");
			so.addParam("quality", "high");
			so.addVariable("headervar", header);
			if ($('#gartner').length !== 0){so.addVariable("imagevar", '/pictures/furniture/gartner.png')}
			so.addParam("wmode", "opaque");
			so.write('sectionheadline');
		}		
	})
	
	
	
	$(".explore_mod").each(function(){
		$(this).find(".azindex").css({'height':($(this).find(".bord").height())-10});
		})

	$(".features_module").each(function(){
			$(this).css({'width':$(this).width()});
			$(this).find("ul:first").show()	
	})

})}})


$.fn.extend({
	//convert select list to ul
turnSelect: function( speed, callback){
		if (this[0] != undefined && this[0].tagName === 'SELECT' ){
			return jQuery.turnSelect( this, speed, callback );
		}
	},
dragger:function(){
		return this.each(function() {
			var timer
			var obj = $(this)
			obj.mousedown(function(k){
				k.preventDefault();
				timer = setTimeout(function(){obj.fadeTo('fast',.6)},150)
				document.selection.clear();
				var oLef = $(this).position().left
				var oTop = $(this).position().top
				$(this).css({'cursor':'-moz-grabbing'})
				$(document).bind('mousemove.dragger',function(e){
					window.getSelection().removeAllRanges();
					var addX = e.pageX - k.pageX
					var addY = e.pageY - k.pageY
					obj.css({'left':oLef+ addX})
					obj.css({'top':oTop+addY})
				})
				$(document).bind('mouseup.dragger',function(){
					clearTimeout(timer)
					obj.fadeTo('fast',1)
					obj.css({'cursor':''})
					window.getSelection().removeAllRanges();
					$(document).unbind('mousemove.dragger')
					$(document).unbind('mouseup.dragger')
				})
			})
		})
	}
});

$.extend({
	// request script
requestScript: function( obj, callback, cache ) {
		var path, syn, selector, requested = 0, loaded = 0;
		//set cache as default
		if(cache != false) {cache = true}
		for (selector in obj){
			path = obj[selector].split(',');
			for (t = 0 ; t < path.length; t++){if ($(selector+':first').length !=0) {requested++
					
				}}
		}
		for (selector in obj){
			path = obj[selector].split(',');
			for (t = 0 ; t < path.length; t++){
				// for existing selectors
				$(selector+':first').each(function(){
					//load required script
					if(path[t].search(/core/) > 1){syn = false} else {syn = true}//set sync
					$.ajax({
						type: "GET",
						url: $.trim(path[t]),
						dataType: "script",
						cache: cache,
						async: syn,
						success:function(){
							sendBack();
						}
					})
				});
			}
		}
		function sendBack(){
			loaded++;
			if(requested === loaded) {
				//In case a callback isn't passed
				if(typeof(callback) == 'function') {
					callback();
				}
			}
		};
	},

	// preload images
preloadImages: function(){
		for(var i = 0; i<arguments.length; i++){jQuery("<img>").attr("src", arguments[i]);}
	},
	// custom question box
questionBox: function(p){
		/*check if it's already created*/
		var msg,yesmsg,nomsg,yesaction,noaction,commer,callBack
		
		
		var sure = "Are you sure?";
		var yesyes = "Okay";
		var nono = "Cancel";
		
		if(lang === 'arabic') {			
				sure = "&#1607;&#1604; &#1571;&#1606;&#1578; &#1605;&#1578;&#1571;&#1603;&#1583;";
				yesyes = "&#1606;&#1593;&#1605;";
				nono = " &#1573;&#1604;&#1594;&#1575;&#1569; &#1575;&#1604;&#1571;&#1605;&#1585;"
		}	
		
		
		if($('.msgbox').length === 0){
			if (p === undefined) {var p = {}}
			if (p.msg) {msg=p.msg} else {msg= sure};
			if (p.truebtn) {yesmsg = p.truebtn} else {yesmsg = yesyes};
			if (p.falsebtn) {nomsg = p.falsebtn} else {nomsg = nono};
			if (p.returnTrue) {yesaction = p.returnTrue} else {yesaction = function(){return}}
			if (p.returnFalse) {noaction = p.returnFalse} else {noaction = function(){return}}
			if (p.callBefore) {callBefore = p.callBefore} else {callBefore = function(){return}}
			if (p.callBack) {callBack = p.callBack} else {callBack = function(){return}}
			if (p.popUp) {
				msg = '<div style="text-align:center;padding:20px 0;"><img id="popupwaiter" src="/pictures/furniture/waiter.gif" /></div>'
				commer = $.ajax({
						url: p.popUp,
						beforeSend: callBefore,
						success: function(){
						var z = commer.responseText
						$('#popupwaiter').fadeOut('normal', function(){$('#ananinami .msg').html(z);callBack();rePos();})
						rePos();
					}
				})
			}
			$("body").append('<div id="ananinami" class="msgbox"><div class="shade_bg"></div><div class="contain"><div class="msg">'+msg+'</div><a href="#here" class="greenbut" id="yesbut"><span>'+yesmsg+'</span></a><a href="#here" class="redbut" id="nobut"><span>'+nomsg+'</span></a></div></div>');
			var ust = (($(window).height()/2) + $(window).scrollTop())-($(".msgbox").outerHeight()/2)
			var sag = $(window).width()/2-($(".msgbox").outerWidth()/2)
			$(".msgbox").fadeIn('fast').css({'top':ust, 'left':sag})		
			$(window).resize(function(){rePos()})
			$(window).scroll(function(){rePos()})
			var rePos = function() {
				ust = (($(window).height()/2) + $(window).scrollTop())-($(".msgbox").outerHeight()/2)
				sag = $(window).width()/2-($(".msgbox").outerWidth()/2)
				$(".msgbox").animate({top:ust},{queue:false},100).animate({left:sag},{queue:false},100,function(){$('.msgbox').stop()})
				$(".msgbox .shade_bg").css({'height':$('#ananinami').height(),'width':$('#ananinami').width()})
			}
			$(window).keyup(function(){rePos();})
			function yesButton() {
				$(".msgbox").stop(true,true).fadeOut('fast', function(){yesaction();$('.contain').unbind('keyup');$("#ananinami").remove();$(window).unbind('resize');$(window).unbind('scroll')})
			}	
			function noButton() {
				$(".msgbox").stop(true,true).fadeOut('fast', function(){noaction();$('.contain').unbind('keyup');$("#ananinami").remove();$(window).unbind('resize');$(window).unbind('scroll')})
			}
			$('.contain').keyup(function(event){
				if (event.keyCode == 27) {
					noButton();
				}
			});
			$(".msgbox #yesbut").mousedown( function(){
				if(p.func){
					func =eval(p.func);
					st=func.apply();
					if(st && p.frm && p.frm=='sendemail'){	
						$.post("popup/email",
						{ sender_email: $("#sender_email").val(), sender_name: $("#sender_name").val(), msg: $("#msg").val(),
id: $("#id").val(),receiver_email:$("#receiver_email").val(),action:'sendemail'},
						function(data){
							article = $(".msgbox .contain .msg form h3:first").html();
							$("#yesbut").css('display','none');
							$("#nobut").css('display','none');
							$(".msgbox .contain .msg form").html(article+'<p style="height:250px;"><dfn>The page has been sent to your friend</dfn></p>');	
							$(".msgbox").stop(true,true).fadeOut(8000, function(){$("#ananinami").remove();noaction();$(window).unbind('resize');$(window).unbind('scroll')});
						}
						);
					}
					
				}
				else{
					yesButton();
				}
			})
			$(".msgbox #nobut").mousedown( function(){
				noButton();
			})
		} else {
			$('.msgbox').find('.msg').text(msg)
		}
		$('#ananinami .shade_bg:first').css({'border-color':'#cc0000'}).animate({borderColor:'#000000'},1000)
		rePos();
	},
	// custom alert box
messageBox: function(p) {
		if($('.msgbox').length === 0){
			if (p === undefined) {var p = {}}
			if (p.msg) {msg=p.msg} else {msg="Please enter a msg"};
			if (p.buttonText) {buttonText = p.buttonText} else {buttonText = "Okay"};
			if (p.func) {func = p.func} else {func = function(){return}}
			$("body").prepend('<div id="ananinami" class="msgbox"><div class="shade_bg"></div><div class="contain"><div class="msg">'+msg+'</div><a href="#here" class="greenbut" id="closebut"><span>'+buttonText+'</span></a></div></div>');
			var ust = (($(window).height()/2) + $(window).scrollTop())-($(".msgbox").outerHeight()/2)
			var sag = $(window).width()/2-($(".msgbox").outerWidth()/2)
			$(".msgbox").css({'left':sag, 'top':ust,opacity:0,'display':'block'}).fadeTo('fast',1)
			
			function rePos(speed) {
				ust = (($(window).height()/2) + $(window).scrollTop())-($(".msgbox").outerHeight()/2)
				sag = $(window).width()/2-($(".msgbox").outerWidth()/2)
				$(".msgbox").animate({top:ust},{queue:false},speed).animate({left:sag},{queue:false},speed)
			}
			
			$(window).resize(function(){rePos(1)})
			$(window).trigger('resize')
			$(window).scroll(function(){rePos(1)})
			
			function closeBox(){
				$(".msgbox").stop(true,true).fadeOut('fast', function(){$(".msgbox").remove();func();$(window).unbind('resize');$(window).unbind('scroll');})}
			$(".msgbox #closebut").mousedown( function(){
				closeBox();
			})
			$('.contain').focus()
			$(document).bind('keyup.msgboxkey', function(event){
				if (event.keyCode == 13 || event.keyCode == 27 ) {
					closeBox();
					$(document).unbind('keyup.msgboxkey')
				}
			});
		} else {
			$('.msgbox').find('.msg').text(msg)
		}
		
		$('#ananinami .shade_bg:first').css({'border-color':'#cc0000'}).animate({borderLeftColor:'#000000',borderRightColor:'#000000',borderTopColor:'#000000',borderBottomColor:'#000000'},1000)
		rePos();
	},
turnSelect: function( obj, speed, callback ){
		var s;
		var cyclecheck = true
		$(obj).wrap("<b id='"+$(obj).attr('id')+"' class='selectb'></b>");
		var new_ul = $(obj).parents('b')
		$(obj).wrap('<i></i>')
		$(obj).find('option').each(function(track){
			if ($(this).attr('selected') && cyclecheck) {
				cyclecheck = false 
				s = '<span>'+$(this).replaceWith('<i class="selected">'+$(this).text()+'</i>').text()+'</span>';
			} else {
				$(this).replaceWith('<i class="">'+$(this).text()+'</i>')
			}
		})
		$(obj).replaceWith('<b>'+$(obj).html()+'</b>')
		new_ul.children('i:first').each(function(){
			$(this).prepend(s)
			var span = new_ul.find('span')
			span.css({'display':'block'})
			var h = $(this).height();
			var ul = $(this).find('b')
			ul.css({'display':'block','position':'absolute'})
			new_ul.css({'width':ul.width(), 'display':'inline-block'})
			ul.find('i').css({'width':$(this).parent().width()})
			span.css({'width':ul.width()})
			new_ul.bind ('click',
			function(e){
				//close menu when click outside
				$('body').bind('click', function(x){
					if ($(x.target)[0] != $(e.target)[0]){
						ul.stop().slideUp(speed);
						$('body').unbind('click')
					}	
				})
				if(ul.css('display') === 'none'){
					ul.stop().slideDown(speed, function(){
						ul.css({'display':'block','height':'auto'})	
					});
				} else if (ul.css('display') === 'block'){
					$('body').unbind('click')
					if ($(e.target).text() != span.text() ) {
						ul.find('i').removeClass('selected')
						$(e.target).addClass('selected')	
						span.text($(e.target).text())
					}
					ul.stop().slideUp(speed, function(){
						ul.css({'display':'none','height':'auto'});
					})
				}
			}
			)
		}).find('b').hide();
		if (callback) {
			callback.call ( new_ul, callback ) 
		}
	},
systemBusy:function(){
		
		$("body").append('<img id="loadergif" src="/pictures/furniture/loader.gif" />');//put loader gif and display until loading complete
		if($('#branding').length !== 0){
			$("#loadergif").css({'position':'absolute','top':$('#brand_menu').position().top+$('#brand_menu').height()+10,'left':($('#brand_menu').position().left+130)})
		}
	},
notBusy:function(){
		$("#loadergif").fadeOut("slow",
		function(){
			$(this).remove()
		}
		) //remove loader gif
	}
});
(function(jQuery){
	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor','borderColor'], function(i,attr){
		jQuery.fx.step[attr] = function(fx){
			if ( fx.state == 0 ) {
				fx.start = getColor( fx.elem, attr );
				fx.end = getRGB( fx.end );
			}
			fx.elem.style[attr] = "rgb(" + [
			Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
			Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
			Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
			].join(",") + ")";
		}
	});
	function getRGB(color) {
		var result;
		if ( color && color.constructor == Array && color.length == 3 )
		return color;
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
		return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
		return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
		return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
		return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
		return colors[jQuery.trim(color).toLowerCase()];
	}
	function getColor(elem, attr) {
		var color;
		do {
			color = jQuery.curCSS(elem, attr);
			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
			break; 
			attr = "backgroundColor";
		} while ( elem = elem.parentNode );
		return getRGB(color);
	};
	var colors = {};
})(jQuery);

$.preloadImages("/pictures/furniture/loader.gif","/pictures/furniture/waiter.gif");



function runNav(){
		/* MAIN NAVIGATION FLYOUT MENU - main menu */
		$("#main_nav").find("li.mmi").each(function(){
			var $that = $(this), menuBut = $(this).find('i:first'),menuText = $(this).children('a:first'), delay = 100, closeDelayer,lan
			if($that.find('ul').length !== 0) {menuBut.show(); menuText.css({'padding-right':'9px'});$that.css({'margin-right':'3px'})}
			$(this).mouseenter(function(){
				$(this).addClass('shover')
				menuBut.mouseenter(function(){$(this).addClass('shover')})
				menuBut.mouseleave(function(){$(this).removeClass('shover')})
				menuBut.click(function(){
					var flyer = $that.find(".main_flyout")
					flyer.css({'visibility':'hidden'})
					var farkW = Math.round ($('#main_nav').width() - (flyer.outerWidth()+($that.position().left)))
					if(farkW < 0) {
						flyer.css({"left":($that.position().left)+farkW});
					} else {
						flyer.css({"left":($that.position().left)});
					}
					$that.addClass('hovered')
					$that.find(".main_flyout").css({'top':($that.position().top)+($that.outerHeight())+10}).show()
					$that.find(".main_flyout").each(function(){
					})
					farkW = Math.round ($('#main_nav').width() - (flyer.outerWidth()+($that.position().left)))
					if(farkW < 0) {
						flyer.css({"left":($that.position().left)+farkW})}
					$('.flyout_bg').css({'width':flyer.width(),'height':flyer.outerHeight()-17})
					flyer.css({'display':'none','visibility':'visible'})
					var showstyle
					flyer.show()
				})
				
			})
			$(this).mouseleave(function(){
				$(this).removeClass('shover')
				closeDelayer = setTimeout (function(){
					$that.find(".main_flyout").hide()
					$that.removeClass('hovered')
				},delay)
			});
		})
		/*----------------------------------------------------------------------------------------------------*/

}
function homeTop() {

	$(".masterhome_show").each(function(){
			var pic = $(this).find(".photos > li")
			var tex = $(this).find(".masterlines > li")
			var thu = $(this).find(".thumbs > li")
			var l = {opacity:0,'display':'none'}
			var buff = null
			var out
			var auto
			var n=0;
			var slidedelay = 10;
			$(this).css({width:$(this).width(),'overflow':'hidden'})
			pic.css(l);	tex.css(l);
			thu.each(function(k){
				$(this).bind('mouseover.operat',function(){
					clearTimeout(out); $(this).unbind('mouseover.operat')
				})
				$(this).bind('mouseover.efect',function(){
					if (buff != null){
						$(thu[buff]).find("img:first").stop().animate({marginTop:10,opacity:0.8},'fast')
						$(tex[buff]).stop().fadeTo('normal',0,function(){$(this).hide()})
						$(pic[buff]).stop().fadeTo('normal',0,function(){$(this).hide()})
					}
					buff = k
					$(this).find("img:first").stop().animate({marginTop:0,opacity:1},'fast')
					$(tex[k]).show().stop().fadeTo('normal',1)
					$(pic[k]).show().stop().fadeTo('normal',1)
				}) 
			})
			function auto() {
				$(thu[n]).trigger('mouseover.efect');
				if (n!=(thu.length-1)) {n++} else {n=0}
				out = setTimeout(auto, (slidedelay*1000))
			}
			auto();

		})
}
function altNav(){

		//very top Alternative Nav script
		$(".alt_nav > ul > li").each(function(){
			menuSpeed = 300
			$(this).click(function(k){
				$(document).unbind('mousedown.altlistener')
				var $that = $(this)
				var div = $(this).find("div")
				var boy = div.css('height')
				$(document).bind('mousedown.altlistener',function(l){
					if(k.target !== l.target){
						$that.find("div").each(function(){
							$(this).animate({height:0},menuSpeed,function(){
								$(this).css({'display':'none','height':boy})
								$that.removeClass('hover')
							})
						})
						$(document).unbind('mousedown.altlistener')
					}
				})
				if (div.css('height') === 'auto') {
					boy = div.height()
				}
				if(div.css('display') === 'none' && $(this).attr('class') !== 'hover') {
					div.css({'height':'0','display':'block'})
					var betray = div.position().left;
					div.animate({height:boy},menuSpeed,function(){div.css({'height':boy, 'left':betray});$that.addClass('hover')})
				}
			})
		})

		$(".alt_nav:first").each(function(){
		if($.browser.msie && jQuery.browser.version < 7){
		$(this).css({"background":"none","filter":"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='scale', src='/pictures/furniture/alt_top.png')","visibility":"visible"});

		} else {
			$(this).css({"background":"none","background":"transparent",'background-image':'url(/pictures/furniture/alt_top.png)'})
			
		}
	});

}



function thumbMod(){
	$('.photos_picture .thumbs:first').each(function(){
	var step = 3 // number of thumbs to slide per click
    var that = $(this)
    var ul = that.find('ul:first')
	var lis = ul.find('li')
	var l = $(lis[0])
	var li = {h:l.height(),w:l.width()+parseInt(l.css('marginRight'))+parseInt(l.css('marginLeft'))+parseInt(l.css('paddingRight'))+parseInt(l.css('paddingLeft'))}
	that.css({height:li.h,'width':'627px',overflow:'hidden','height':'62px'})
	if((li.w*lis.length) > that.width()) {
	ul.css({width:(li.w+3)*lis.length,'margin-left':'19px','margin-top':'8px'})
	console.log()
	that.prepend('<div class="butglob" id="slideback" style="background:url(/application/views/itpnet/css/cssimg/gallerybut.png) no-repeat right;position:absolute;height:62px; width:23px;z-index:3"></div>')
	that.prepend('<div class="butglob" id="slidefor" style="background:url(/application/views/itpnet/css/cssimg/gallerybut.png) no-repeat left;position:absolute;height:62px; width:23px;z-index:3"></div>')

	$('#slideback').css({left:that.position().left,opacity:.9})
	$('#slidefor').css({left:that.position().left+that.width()-$('#slidefor').width(),opacity:.9})
	
	var mMargin = parseInt(ul.css('marginLeft'))
	$('.butglob').hover(
		function(){
			$(this).stop().fadeTo('fast',1)
		},
		function(){
			$(this).stop().fadeTo('fast',.9)
		}
	)
	
	
	
	$('#slidefor').click(function(){
	var mMargin = parseInt(ul.css('marginLeft'))
	console.log(Math.abs(mMargin) +' - ' + ul.width())
	
	if(Math.abs(mMargin) < (ul.width()-650)){
			ul.animate({marginLeft:(mMargin = mMargin-(li.w*step))},'slow')
		}
	})
	$('#slideback').click(function(){
	var mMargin = parseInt(ul.css('marginLeft'))
		if(mMargin < li.w){
			ul.animate({marginLeft:(mMargin = mMargin+(li.w*step))},'slow')
		}
	})
	}
})

}

function runLogin(){
	$('#mainlogin').each(function(){
		var host=''
		var loglan = "Login"
		if(lang === 'arabic') {			
				loglan = '&#1578;&#1587;&#1580;&#1610;&#1604; &#1575;&#1604;&#1583;&#1582;&#1608;&#1604;'
				host = '/arabic'	
		}	
		
		var link = $(this).attr('href');
		$(this).attr('href','#:here');
		$(this).click(function(){
			$.questionBox({popUp:host+'/popup'+link,
				callBack:function(){
					$('.msg .sendem input:submit').hide();
				},
				truebtn: loglan,
				returnTrue:function(){
					$('#shell').fadeTo('fast',0.3);
					document.loginfrm.action.value='login';
					document.loginfrm.submit();
				}
			});
		});
	});
}	
	function openPicWindow(wPage,width,height,resize) {
		window.open(wPage,'window','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=' + resize + ',channelmode=no,directories=no,width=' + width + ',height=' + height + ',top=10,left=10');
	}
