var tab_label = 1;
function tabToggle(obj) {
	var label = obj.id.split("_")[1];
	if (tab_label != label) {
		var o1 = document.getElementById("Tab_" + tab_label).src;
		var o2 = document.getElementById("Tab_" + label).src;
		document.getElementById("Tab_" + tab_label).src = o1.substring(0,o1.length-6) + o1.substring(o1.length-6,o1.length-5) + ".gif";
		document.getElementById("Tab_" + label).src = o2.substring(0,o2.length-5) + o2.substring(o2.length-5,o2.length-4) + "_.gif";
		document.getElementById("Contain_" + tab_label).style.display = "none";
		document.getElementById("Contain_" + label).style.display = "";
		tab_label = label;
		obj.blur();
	}
	else {
		obj.blur();//
		return;
	}
}
function linkTabToggle(id) {
	var label = id;
	if (tab_label != label) {
		document.getElementById("Tab_" + tab_label).className = "";
		document.getElementById("Tab_" + label).className = "ShowThisTab";
		document.getElementById("LinkContain_" + tab_label).style.display = "none";
		document.getElementById("LinkContain_" + label).style.display = "";
		tab_label = label;
	}
	else {
		return;
	}
}
function tabIndustry(obj) {
	var oLabel = obj.id.split("_")[1];
	if (tab_label != oLabel) {
		document.getElementById("InTab_" + oLabel).className = "IndustryIsThis";
		document.getElementById("InTabB_" + oLabel).className = "IndustryIsThis";
		document.getElementById("InTab_" + tab_label).className = "";
		document.getElementById("InTabB_" + tab_label).className = "";
		document.getElementById("Industry_" + tab_label).style.display = "none";
		document.getElementById("Industry_" + oLabel).style.display = "";
		tab_label = oLabel;
		obj.blur();
	}
	else {
		obj.blur();//
		return;
	}
}


function checkImg(theURL, winName) {
	if (typeof(imgObj) == "object"){
		if ((imgObj.width != 0) && (imgObj.height != 0)) {
			var x = window.screen.width - 10;
			var y = window.screen.height;
			var w = imgObj.width + 20;
			var h = imgObj.height + 30;
			var left,top;
			if(x > w) {
				left = (x - w) / 2;
			}
			else {
				left = 0;
			}
			if(y > h) {
				top = (y - h) / 2;
			}
			else {
				top = 0;
			}
			var str = ",width=" + w + ",height=" + h + ",left=" + left + ",top=" + top;
			OpenFullSizeWindow(theURL, winName, str); 
		}
		else {
			setTimeout("checkImg('" + theURL + "','" + winName + "')", 100);
		}
	}
}

function OpenFullSizeWindow(theURL, winName, features) {
	sBaseCmd = "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,";
	if (features == null || features == ""){
		imgObj = new Image();
		imgObj.src = theURL;
		checkImg(theURL, winName);
	}
	else{
		aNewWin = window.open(theURL, winName, sBaseCmd + features);
		aNewWin.focus(); 
	}
}

function ChkImgSize(strImg, iWidth, iHeight) {
	imgObj = new Image();
	imgObj.src = strImg;
	if (imgObj.width >= iWidth){
		document.write("<img src='" + strImg + "' width='" + iWidth + "' border='0' />"); 
	}
	else if (imgObj.height >= iHeight){
		document.write("<img src='" + strImg + "' height='" + iHeight + "' border='0 />"); 
	}
	else{
		document.write("<img src='" + strImg + "' width='" + imgObj.width + "' border='0 />"); 
	}
}

function imgOpen(obj) {
	var u = obj.src;
	OpenFullSizeWindow(u.substr(0,u.length-5)+u.substr(u.length-4,u.length),"","")
}
function noSmallImgOpen(obj) {
	OpenFullSizeWindow(obj.src,"","")
}
function fOpenCenterWin(theURL,winName,w,h,otherFeatures){
	var x = window.screen.width - 10;
	var y = window.screen.height;
	var left,top;
	if(x > w) {
		left = (x - w) / 2;
	}
	else {
		left = 0;
	}
	if(y > h) {
		top = (y - h) / 2;
	}
	else {
		top = 0;
	}
	if(otherFeatures + '' == ''){
		otherFeatures = ",resizable=yes";
	}
	var str = "width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + otherFeatures;
	window.open(theURL,winName,str);
}

function mon(d) {
	var o = d.src;
	return 	d.src = o.substring(0,o.length-5) + o.substring(o.length-5,o.length-4) + "_.gif";
}
function mout(d) {
	var o = d.src;
	return 	d.src = o.substring(0,o.length-6) + o.substring(o.length-6,o.length-5) + ".gif";
}
function showLevel2Div() {
}
function showDiv(StrID) {
	var o = $("#Top2");
	var s = $("#ShowLoading");
	var getShow = function(id) {
		s.show();
		$.ajax({ 
			"type": "get", 
			"url":"../handler/Handler1.ashx?id=" + id, 
			"success": function(data) { 
				s.hide();
				o.css('opacity','0.92').show('fast');
				$("#Top2").html(data); 
			},
			"error": function(){
				$("#Top2").html(data);}
		});
	}
	if (o.is(':visible')) {
		o.hide('fast');
		getShow(StrID);
	}
	else{
		getShow(StrID);
	}
}
function closeDiv() {
	$("#Top2").hide('slow');
}

function ShowError(obj) {
  obj.src = "../Images/LoadLogo.jpg";
}

jQuery.fn.autoZoomLoadImage = function(scaling, width, height, loadPic){
    if(loadPic == null) loadPic="../Images/WhiteLoader.gif";
    return this.each(function(){
        var t = $(this);
        var src = $(this).attr("src");
        var img = new Image();
        //alert("Loading")
        img.src = src;
       
        var autoScaling = function(){
            if(scaling){
                if(img.width > 0 && img.height > 0){ 
                    if(img.width / img.height >= width / height){ 
                        if(img.width > width){ 
                            t.width(width); 
                            t.height((img.height * width) / img.width); 
                        }
						else{ 
                            t.width(img.width); 
                            t.height(img.height); 
                        } 
                    } 
                    else{ 
                        if(img.height > height){ 
                            t.height(height); 
                            t.width((img.width * height) / img.height); 
                        }
						else{ 
                            t.width(img.width); 
                            t.height(img.height); 
                        } 
                    } 
                } 
            }    
        }
       
        if(img.complete){
            //alert("getToCache!");
            autoScaling();
            return;
        }
        $(this).attr("src","");
        var loading = $("<img alt=\"\" title=\"\" src=\"" + loadPic + "\" />");
        t.hide();
        t.after(loading);
        $(img).load(function(){
            autoScaling();
            loading.remove();
            t.attr("src",this.src);
            t.show();
           
        });
    });
}

