// JavaScript Document
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

var popuppage;
var checkpopup;
/*
function setpreviewpopupfn(fieldname,type,change,ww,wh,imgfoldername){
*/
function setpreviewpopupfn(fname,ww,wh,imgfoldername){
	var	fieldname;
	var type;
	var change;
	var swfwidth;
	var swfheight;
	var filename;
	var filetype;
	var imgchange;
	var sendfilename;
	var winwidth;
	var winheight;
	var fwidth;
	var fheight;

	fieldname = fname+'imagename';
	type = fname+'type';
	change = fname+'imagechange';
	swfwidth = fname+'width';
	swfheight = fname+'height';
	
	 if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
			filename = document.getElementById(fieldname).value;
			filetype = document.getElementById(type).value;
			imgchange = document.getElementById(change).value;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
			 filename = document.all[fieldname].value;
			 filetype = document.all[type].value;	
			 imgchange = document.all[change].value;	
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
			 filename = document.layers[fieldname].value;
			 filetype = document.layers[type].value;
			 imgchange = document.layers[change].value;
    	} 
		
		if (filetype == "Flash")
		{
			if (document.getElementById) 
   		 	{ 
			fwidth = document.getElementById(swfwidth).value;
			fheight = document.getElementById(swfheight).value;
			} 
			else if (document.all) 
			{ 
			 fwidth = document.all[swfwidth].value;
			 fheight = document.all[swfheight].value;	
			 } 
			 else if (document.layers) 
			 { 
			 fwidth = document.layers[swfwidth].value;
			 fheight = document.layers[swfheight].value;
			 }
		}
		else
		{
		fwidth = ww;
		fheight = wh;
		}
		
		winwidth = (fwidth*1)+20;
		winheight = (fheight*1)+20;
		
		
		sendfilename = 'admin_preview_page.asp?fname='+filename+'&ftype='+filetype+'&cvalue='+imgchange+'&w='+fwidth+'&h='+fheight+'&imgf='+imgfoldername;
		//alert(filename)
		popuppagefn(sendfilename, winwidth, winheight, 'no');
}

function chkfield(fieldname,btnname){
	var previewbtn;
	var getfield;
	if (document.getElementById) 
   	{ 
       	// this is the way the standards work 
		getfield = document.getElementById(fieldname);
		previewbtn = document.getElementById(btnname);
   	} 
   	else if (document.all) 
   	{ 
       	// this is the way old msie versions work 
		 getfield = document.all[fieldname];	
		 previewbtn = document.all[btnname];	
   	} 
  	else if (document.layers) 
   	{ 
        // this is the way nn4 works 
		getfield = document.layers[fieldname];
		previewbtn = document.layers[btnname];
    } 	
	
	if (getfield.value == "")
	{
		btndisabled(btnname);
	}
	else
	{
		btnenabled(btnname);		
	}
	
}

function popuppagefn(pages, ww, wh, scrbar){
  var winwidth = ww;
  var winheight = wh;
  var posX =(screen.width-winwidth)/2;
  var posY =(screen.height-winheight)/2;

  var setting = 'width='+winwidth+',';
  setting += 'height='+winheight+',';
  setting += 'top='+posY+',';
  setting += 'left='+posX+',';
  setting += 'scrollbars='+scrbar+',';
  setting += 'alwayRasied=yes';
  popuppage = window.open(pages,'popupname',setting);		
  //checkpopup = true;
};


function winpopup(mylink, ww, wh, resize) {
  if (! window.focus) return true; 
    var newwin; 
    var href;
    var winwidth = ww;
    var winheight = wh;
    var posX =(screen.width-winwidth)/2;
    var posY =(screen.height-winheight)/2;

    var setting = 'width='+winwidth+',';
    setting += 'height='+winheight+',';
    setting += 'top='+posY+',';
    setting += 'left='+posX+',';
    setting += 'scrollbars=no,';
    setting += 'resizable='+resize+',';
    setting += 'alwayRasied=yes';
    
	if (typeof(mylink) == 'string'){
      href=mylink;
    } else {
      href=mylink.href;
    };
     newwin = window.open(href, 'NewWindow', setting);
     return false;
}

function closepopuppage(){
  //if (popuppage != null) {
    popuppage.close();
    //popuppage = null;
    //checkpopup = false;
  // }
  // else {
    //popuppage = null;
    //checkpopup = false;
  // };
};

function changeImage(pict,imgid,ftype,actype,ext,swfw,swfh){
	   var pictname = imgid+"image";
	   var hiddenfieldvalue = imgid+"imagename";
	   var chkchangeimage = imgid+"imagechange";
	   var btnname = imgid+"btn";
	   var thispict = "tmpuploadimg/"+pict;
	   var typefield = imgid+"type";
	   var filetype;
	   if (ext != 'swf'){
		   filetype = "Image";
	   }
	   else
	   {
		   filetype = "Flash";	   
	   }
	   	 btndisabled(btnname);
		 changehiddenimgvalue(hiddenfieldvalue,pict);
		if (actype == "update")
		{
			setchangeimagevalue(chkchangeimage);
		}
		else
		{
			if (filetype == "Flash")
			{
			setchangeimagevalue(chkchangeimage);	
			chkfield(hiddenfieldvalue,'previewbtn');
			}
		}
		
		if (ftype == 1)
	  	{
			changeimgsrc(pictname,thispict);
		}
		if (ftype == 2)
	  	{
			changeswfwh(imgid,swfw,swfh)
			changeimgtyprval(typefield,filetype);
			chkfield(hiddenfieldvalue,'previewbtn');
		}
		if (ftype == 3)
	  	{
			changeswfwh(imgid,swfw,swfh)
		}

		closepopuppage();
}

function changeswfwh(whichfield,w,h){
	var swfwidth = whichfield+"width";
	var swfheight = whichfield+"height";
	if (document.getElementById) 
   	{ 
       		 // this is the way the standards work 
		document.getElementById(swfwidth).value = w;
		document.getElementById(swfheight).value = h;
   	} 
   	else if (document.all) 
   	{ 
       		 // this is the way old msie versions work 
		document.all[swfwidth].value = w;	
		document.all[swfheight].value = h;	
   	} 
   	else if (document.layers) 
   	{ 
        	// this is the way nn4 works 
		document.layers[swfwidth].value = w;
		document.layers[swfheight].value = h;
   	} 
	
}

function changeimgtyprval(whichfield,typeval){
		 if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
        	//document.getElementById(whichButton).disabled = true; 
			document.getElementById(whichfield).value = typeval;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
       		 //document.all[whichButton].disabled = true; 
			 document.all[whichfield].value = typeval;			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
       		 //document.layers[whichButton].disabled = true; 
			 document.layers[whichfield].value = typeval;
    	} 
}

function changehiddenimgvalue(whichimage,pict){
		 if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
        	//document.getElementById(whichButton).disabled = true; 
			document.getElementById(whichimage).value = pict;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
       		 //document.all[whichButton].disabled = true; 
			 document.all[whichimage].value = pict;			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
       		 //document.layers[whichButton].disabled = true; 
			 document.layers[whichimage].value = pict;
    	} 
}

function changeimgsrc(whichimage,thispict){
		 if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
        	//document.getElementById(whichButton).disabled = true; 
			document.getElementById(whichimage).src = thispict;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
       		 //document.all[whichButton].disabled = true; 
			 document.all.images[whichimage].src = thispict;
			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
       		 //document.layers[whichButton].disabled = true; 
			 document.layers.images[whichimage].src = thispict;
    	} 
}

function btndisabled(whichbtn){
	   	  if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
			document.getElementById(whichbtn).disabled = true;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
			 document.all[whichbtn].disabled = true;
			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
			 document.layers[whichbtn].disabled = true;
    	} 	
}

function btnenabled(whichbtn){
	   	  if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
			document.getElementById(whichbtn).disabled = false;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
			 document.all[whichbtn].disabled = false;
			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
			 document.layers[whichbtn].disabled = false;
    	} 	
}

function setchangeimagevalue(whichfield){
	   	 if (document.getElementById) 
   		 { 
       		 // this is the way the standards work 
			document.getElementById(whichfield).value = 1;
   		 } 
   		 else if (document.all) 
   		 { 
       		 // this is the way old msie versions work 
			document.all[whichfield].value = 1;
			 
   		 } 
   		 else if (document.layers) 
   		 { 
        	// this is the way nn4 works 
			 document.layers[whichfield].value = 1;
    	} 	
}

