var viewurl= document.URL.substring(7)
viewurl=viewurl.substring(0,viewurl.indexOf("/")+1)
var pre= document.URL.substring(0,7)

function customOnLoad() {

 //if(navigator.appName == "Microsoft Internet Explorer") fixObjects();
}
window.onload=customOnLoad;

function viewVideo(id) {
   
    mywindow = window.open(pre + viewurl + 'custom/viewvideo.aspx?id=' + id, '','location=0,status=0,scrollbars=0, width=480,height=380');
    mywindow.moveTo((screen.width/2)-240,0);
    mywindow.focus()
}

function changeArticlePart(e) {
    var url=window.location.href;
    var path;
    var page;
    var extension = url.substring(url.lastIndexOf('.'))
    
    path = url.substring(0,url.lastIndexOf('/')+1);
    page = url.substring(path.length);
    
    if (page.indexOf('-')==-1) {
        page=page.substring(0,page.indexOf('.'));
    }else{
        page=page.substring(0,page.indexOf('-'));
    }
   url= path + page + "-" + e.selectedIndex + extension;
    window.location.href=url;

}

function doSearch(txtq) {
    var q=document.getElementById(txtq).value
    if (q!="") {
        //window.location.href=pre + viewurl + "custom/search.aspx?query="+q
		
		window.location.href="http://www.google.com/search?hl=en&lr=&domains=" + viewurl + "&q=" + q +"&btnG=Search&sitesearch=" + viewurl;
    }
}

function doLogin() {
    var login=document.getElementById("div16")
     login.style.display = login.style.display=="block" ? "none" : "block";
}

function fixObjects() {
	objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
		objects[i].outerHTML = objects[i].outerHTML;
	}
}

function image_displayLarge(img) {
 WebService.image_returnData(img.id.substring(5),image_displayLargeOnComplete,image_displayLargeOnTimeOut)

}

function image_displayLargeOnComplete(response) {
var img=document.getElementById("image"+response.Id)

var winwidth=getWidth() / 2;
winwidth=winwidth-350;

    var largeDiv = document.createElement("div");
    largeDiv.style.position="absolute";
    largeDiv.style.width="700px";
    largeDiv.style.top=findPosY(img)+"px";
    largeDiv.style.left=winwidth + "px";
    largeDiv.style.border="inset 1px black";
    largeDiv.style.backgroundColor="white";
    var heading = document.createElement("div");
    //heading.style.borderBottom="1px dotted grey";
    var headingleft = document.createElement("div")
    headingleft.appendChild(document.createTextNode(response.Title));
    headingleft.style.width="594px"
    headingleft.style.fontSize="12px";
    headingleft.style.padding="3px";
    var headingright = document.createElement("div")
    headingright.style.width="94px";
    headingright.style.padding="3px";
    headingright.style.cursor="pointer";
    headingright.appendChild(document.createTextNode("[Steng]"));
//    headingright.onclick="document.body.removeChild(largeDiv)";

headingright.style.zIndex="100";
    headingright.style.textAlign="right";
			    if(navigator.appName == "Microsoft Internet Explorer") {
			    headingleft.style.styleFloat="left";
			    headingright.style.styleFloat="left";
			    headingright.onclick = function() {document.body.removeChild(this.parentNode.parentNode)};
			    }else{
			    headingright.setAttribute("onclick","document.body.removeChild(this.parentNode.parentNode)");
			    headingleft.style.cssFloat="left";
			    headingright.style.cssFloat="left";
			    }
			    
			      
    heading.appendChild(headingleft)
    heading.appendChild(headingright)
    largeDiv.appendChild(heading);
    var limg = document.createElement("img")
    limg.setAttribute("src","image" + response.Id + "@700x0.img");    
    
    largeDiv.appendChild(limg);
    var t = document.createElement("div");
    t.appendChild(document.createTextNode(response.Description));
    largeDiv.appendChild(t);    

    document.body.appendChild(largeDiv);


}
function image_displayLargeOnTimeOut(response) {

}

			function getWidth() {
				if (self.innerWidth){ //Firefox
					return self.innerWidth;
				}
				else if (document.documentElement && document.documentElement.clientWidth){ //IE6
					return document.documentElement.clientWidth+17;
				}
				else if (document.body){
					return document.body.clientWidth;
				}
			}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getPlayer(player,video,splash,autostart,width,height){
	var playerString;

	playerString='<object type="application/x-shockwave-flash" data="/static/player/' + player + '.swf" width="'+width+'" height="'+height+'">';
	playerString+='<param name="movie" value="/static/player/' + player + '.swf" />';
	playerString+='<param name="FlashVars" value="movieName=/static/videos/video' + video + '&amp;jpgFile=/static/videos/video' + splash + '&amp;autoplay='+autostart+'" />';
	playerString+='<param name="quality" value="high"/><param name="menu" value="false"/></object>';
	document.write(playerString);
}