/* RETURN OBJECT*/
function _i(id){
 objd = d.getElementById(id);	
 return objd;	
}

/*RESIZE TEXT FUNCTIONS*/
var maxsize ='16';
var minsize ='9';
var cursize = 11;
function BiggerSize(){
 if(cursize<=maxsize){
    cursize++;
	SetSize(cursize);
 }
}
function SmallerSize(){
 if(cursize>=minsize){
    cursize--;
	SetSize(cursize);
 }
}
function SetSize(newsize){
    document.getElementById('bodytext').style.cssText = "font-size:"+newsize+"px;";
}
/* HIDES AND DISPLAYS A SINGLE OBJECT*/
function SH(id) {

  el = document.getElementById(id);
  if (el.style.display == 'block') {
    el.style.display = 'none';
  }
  else {
    el.style.display = 'block';
  }
};

/* HIDES AND DISPLAYS SPECIFIED objects*/
function ShowHide(objtoshow,objtohide,border){//'all,fromupload','fromurl',','
	var toshowArr = new Array();
	var tohideArr = new Array();

    toshowArr = str_to_arr(objtoshow,border);
	tohideArr = str_to_arr(objtohide,border);

	// display needed divs 
	for($i=0;$i<toshowArr.length;$i++){
		document.getElementById(toshowArr[$i]).style.display    = 'block';
	}
	// hide needed divs 
	for($i=0;$i<tohideArr.length;$i++){
		document.getElementById(tohideArr[$i]).style.display    = 'none';
	}
};

function str_to_arr(str,border){
  var arr=str.split(border);
  return arr;
};

function in_array(strr,marray){
	for(i=0;i<marray.length;i++){
		if(marray[i]==strr){
			return 1;
		}
	}
	return 0;
};
function MVR(paramVar1)
{
//document.getElementById("trnsprant"+paramVar1).style.cursor = "hand";
document.getElementById("trnsprant"+paramVar1).className = "vsb";


}
function MOT(paramVar1)
{
document.getElementById("trnsprant"+paramVar1).className = "trsp";
}
function GetLoc(loc)
{
window.location=loc;
}
function Colorchange(a,color){
document.getElementById(a).bgColor=color;
}

function Applysub(id)
{document.getElementById(id).style.display='block';
}

function ChangePreview(that,photo_title,path,preview_href){
//document.getElementById(id).style.display='block';
document.getElementById('preview').innerHTML='<a href='+preview_href+'><div  onClick="" style="cursor:pointer"><DIV STYLE="position:relative;left:0px;top:0px;padding:10px;cursor:hand;" TITLE="'+photo_title+'"><img  style="border:1px solid #666666;" src="'+path+'" TITLE="'+photo_title+'" ALT="'+photo_title+'"></DIV></DIV></a> ';
//alert(document.getElementById('preview').innerHTML);
//alert(id);
}



// -----------------------------------------------------
// Get window width in pixels; returns 0 if unidentifiable.
// -----------------------------------------------------
function getWindowWidth(){
  var ww = 0;
  d = document;
   if ( typeof window.innerWidth != 'undefined' )
     ww = window.innerWidth;  // NN and Opera version
   else
   {
     if ( d.documentElement
       && typeof d.documentElement.clientWidth!='undefined'
       && d.documentElement.clientWidth != 0 )
       ww = d.documentElement.clientWidth;
     else
       if ( d.body
         && typeof d.body.clientWidth != 'undefined' )
         ww = d.body.clientWidth;
     else alert ("Can't identify window width - please tell me which browser you are using.")
   }
   return ww;
}


function getWindowHeight(){
  var ww = 0;
  d = document;
   if ( typeof window.innerHeight != 'undefined' )
     ww = window.innerHeight;  // NN and Opera version
   else
   {
     if ( d.documentElement
       && typeof d.documentElement.clientHeight!='undefined'
       && d.documentElement.clientHeight != 0 )
       ww = d.documentElement.clientHeight;
     else
       if ( d.body
         && typeof d.body.clientHeight != 'undefined' )
         ww = d.body.clientHeight;
     else alert ("Can't identify window width - please tell me which browser you are using.")
   }
   return ww;
}

// -----------------------------------------------------
// Adjust image size according to window width
// -----------------------------------------------------

function resizeimg(id,src,status) {
  var ww = getWindowWidth();
  var wh=getWindowHeight();
  var im_wo=document.getElementById("myimg").width;
  var im_w=document.getElementById("myimg").width+300;
  var im_h=document.getElementById("myimg").height;
  var iw,ih;
  var text;
  status=Math.abs(status-1);
 var proportion;

        if (status==0){
             remainder_w=im_w-ww;
             remainder_h=im_h-wh;
             remainder_w_h=remainder_w-remainder_h;

	         if((remainder_w>=0)&&(remainder_h<=0)){
	                 iw=ww-300;
					 proportion=iw/im_wo;
                     ih=im_h*proportion;
                     document.getElementById('msg').style.display='block';
             }
             if((remainder_h>=0)&&(remainder_w<=0)){
	                 
                     ih=wh;
                     proportion=ih/im_h;
                     iw=im_wo*proportion;
                    document.getElementById('msg').style.display='block';
            }
           if((remainder_h>=0)&&(remainder_w>=0)){
	                     if ( remainder_w_h>=0){
							     iw=ww-300;
                                proportion=iw/im_wo;
                                ih=im_h*proportion;
                                 document.getElementById('msg').style.display='block';
                         }
	                    if ( remainder_w_h<=0){
							  ih=wh;
                     proportion=ih/im_h;
                     iw=im_wo*proportion;
                                 document.getElementById('msg').style.display='block';
                        }
            }
          if((remainder_h<=0)&&(remainder_w<=0)){
                          iw=im_wo;
	                      ih=im_h;
                         document.getElementById('msg').style.display='none';
         }
   document.getElementById(id).innerHTML='<img id="myimg" src='+src+' width="'+iw+'"  height="'+ih+'"  onclick=resizeimg("'+id+'","'+src+'","'+status+'");>';
 // alert(document.getElementById(id).innerHTML);
  }
 


   if (status==1){

      document.getElementById('msg').style.display='none';
 document.getElementById(id).innerHTML='<img id="myimg" src='+src+'   onclick=resizeimg("'+id+'","'+src+'","'+status+'");>';
 // alert(document.getElementById(id).innerHTML);
  }

}

function showsize(){
  alert("Window width = " + getWindowWidth());
}

