/* common js */

 

function menu_drop(menuId, display)
{
	$id(menuId).style.display=display;
}

function $id(id)
{
	return document.getElementById(id);
}

function mobile_filter()
{

    var w= $('#show_text_inc').width();
    var h = $('#show_text_inc').height();
    var ps = getPageSize();
    var m_w = ps[0] , m_h = ps[1];
    var v_w = ps[2], v_h= ps[3] ;

    $('#overlay').css("width",  m_w + 'px').css("height", m_h + 'px' ).show().animate({opacity:0.5}, 200, 'easeInQuad', function(){
	if($.browser.msie6)
	{
		var sc = getPageScroll();
		var scy = sc[1] ;
		$('#show_text_inc').css("top",(v_h-h)/2+scy ).css("left",(v_w - w)/2 ).show();
	 }
	 else
	 {
		 $('#show_text_inc').css("top",(v_h-h)/2 ).css("left",(v_w - w)/2 ).show();
	 }

    });
}

function hidefilter()
{
	$('#overlay').css("opacity", 0 ).hide();
	$('#show_text_inc').hide();
	//$('#show_text_inc').css("opacity", 0 );
}
function submit_filter()
{
	$('#filter_form').submit() ;
}


function getPageSize() {

	var xScroll, yScroll , pageWidth, pageHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (document.documentElement
			&& document.documentElement.clientHeight) {
		// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	} else if (self.innerHeight) {
		// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	var arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
	return arrayPageSize;
}
function getPageScroll() {
	var yScroll, xScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		// Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {
		// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;
	}

	var arrayPageScroll = new Array(xScroll, yScroll);
	// arrayPageScroll = new Array('',yScroll);
	return arrayPageScroll;
}


function isScroll()
{
		return  $(window).height() == $(document).height() ? false : true ;
}

 function scroll_position(id)
 {
		var o = $('#'+id) ;
		var offsetY = $(window).height() - o.height() + $(document).scrollTop();
		o.stop(true, false).animate({top:offsetY},{duration:500,queue:false});
		if($(document).scrollTop()==0)
		{
		    $('#go_top').hide();
		    $('#go_bottom').show();
		}
		else if($(document).scrollTop()==$('body').height() - $(window).height())
		{
		    $('#go_top').show();
		    $('#go_bottom').hide();
		}
		else
		{
		    o.find('a').show();
		}
		if(!isScroll())
		{
			$('#go_top_bottom').hide();
		}
		else
		{
			 $('#go_top_bottom').show();
		}
}
function scroll_to_pos(pos)
{
		var scrollY = 0 ;
		if(pos=='top')
		{
		    scrollY = 0;
		}
		else if(pos=='bottom')
		{
		    scrollY = $('body').height() - $(window).height() ;
		}
		$('html,body').animate({scrollTop: scrollY}, 800);
}


 
/*
$(function() {
		var userAgent = window.navigator.userAgent.toLowerCase();

		$.browser.msie8 = $.browser.msie && /msie 8\.0/i.test(userAgent);
		$.browser.msie7 = $.browser.msie && /msie 7\.0/i.test(userAgent);
		$.browser.msie6 = !$.browser.msie8 && !$.browser.msie7 && $.browser.msie && /msie 6\.0/i.test(userAgent);
});
*/


function correctPNG()  
{  
	if(navigator.appVersion.indexOf("MSIE")){
	 var arVersion = navigator.appVersion.split("MSIE");
     var version = parseFloat(arVersion[1]);
     if (version < 8)
     {
        
       for(var j=0; j<document.images.length; j++)
       {
           var img = document.images[j];
           var imgName = img.src.toUpperCase();
           if (imgName.substring(imgName.length-3, imgName.length) == "png")
           {
             var imgID = (img.id) ? "id='" + img.id + "' " : "";
             var imgClass = (img.className) ? "class='" + img.className + "' " : "";
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
             var imgAlt = (img.alt) ? "alt='" + img.alt + "' " : "alt='" + img.title + "' ";
             var imgStyle = "display:inline-block;" + img.style.cssText;
             if (img.align == "left") imgStyle = "float:left;" + imgStyle;
             if (img.align == "right") imgStyle = "float:right;" + imgStyle;
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
             var strNewHTML = "<span " + imgID + imgClass + imgTitle +  " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
             img.outerHTML = strNewHTML;
             j = j-1;
           }
       }
     }
    }    
}
$(document).ready(function(){
    	correctPNG();
    });

