/*****************************************************************************************************
Created By: Jalal el SHAER
Created On: 10 April 2006
Last Modified: 17/1/2007
******************************************************************************************************/
var HostPath = "/FullMobileWebsite/";

		//Generating Pop-up Print Preview page
		function FM_GetPrint(print_area)
		{			
			//Creating new page
			var pp = window.open();
			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href="' + HostPath + 'Styles/Style_blue.css"  type="text/css" rel="stylesheet">');
			pp.document.writeln('<base target="_self"></HEAD>');
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			pp.document.writeln('<form  method="post">');
			//Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width="100%" cellpadding="10px"><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			//Writing print area of the calling page
			pp.document.writeln(document.getElementById(print_area).innerHTML);
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');
			
		}	
		// Show picture in a separate window	
		function FM_ShowPicture(imagePath, width, height, popup)
		{
		    // Ensure proper picture size
			var myWidth, myHeight;
			if(width > 800)
			{
			    myWidth = 800;
			    myHeight = 800 * (height/width);			    
			}
			else if (height > 600)
			{
			    myHeight = 600;
			    myWidth = 600 * (width/height);			
			}
            else
            {
            	myWidth = width;
			    myHeight = height;
            }
            //Creating new page
		    // add 35 pixels  to the height for the menu
            var wleft = (screen.width - myWidth) / 2;
            var wtop = (screen.height - myHeight) / 2;
            if(popup)
            {
                var winprops = 'height='+eval(myHeight+75)+',width='+myWidth+',top='+wtop+',left='+wleft+', status=no,scrollbars=no,resize=no';
		        var pp = window.open("","", winprops);
		        // Just in case width and height are ignored
                pp.resizeTo(myWidth, eval(myHeight+75));
                // Just in case left and top are ignored
                pp.moveTo(wleft, wtop);
                pp.focus();

			    //Adding HTML opening tag with <HEAD> … </HEAD> portion 
			    pp.document.writeln('<HTML><HEAD><title>Fullmobile - Picture Preview</title>');
			    pp.document.writeln('<base target="_self"></HEAD>');
			    //Adding Body Tag
			    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			    //Adding form Tag
			    pp.document.writeln('<form  method="post">');
			    //Creating two buttons Print and Close within a table
			    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			    //Writing print area of the calling page
			    pp.document.writeln("<img src='" + imagePath +"' Width=" + myWidth + " Height=" + myHeight + " alt='' style='border: 0;' />");
			    //Ending Tag of </form>, </body> and </HTML>
			    pp.document.writeln('</form></body></HTML>');			    
		    }
		    else // pop-in
		    {
		        var divContainer = document.getElementById('$$__Container__$$');
                if(divContainer == null)
                { 
                    divContainer = document.createElement("DIV");
                    divContainer.id = "$$__Container__$$";            
                    divContainer.style.position = "absolute";
                }
                divContainer.style.height= eval(myHeight+75);
                divContainer.style.width= myWidth;
                divContainer.style.top= wtop;
                divContainer.style.left=wleft;
                divContainer.style.display = 'block';
                divContainer.style.zIndex = 10000;

			    //Creating two buttons Print and Close within a table
			    var content = "<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID=\"CLOSE\" type=\"button\" value=\"Close\" onclick=\"document.getElementById('$$__Container__$$').style.display='none';\"></TD></TR><TR><TD></TD></TR></TABLE>";			
			    //Writing print area of the calling page
			    content = content + "<img src='" + imagePath +"' Width=" + myWidth + " Height=" + myHeight + " alt='' style='border: 0;' />";
                
                divContainer.innerHTML = content;            
		        document.body.appendChild(divContainer);
		    }
		}

        // Show audio/video in a separate window	
		function FM_ShowAudioVideo(mediaPath)
		{
		    var myWidth = 325;
		    var myHeight = 245;
            //Creating new page
		    // add 35 pixels  to the height for the menu
            var wleft = (screen.width - myWidth) / 2;
            var wtop = (screen.height - myHeight) / 2;
            var winprops = 'height='+eval(myHeight+50)+',width='+myWidth+',top='+wtop+',left='+wleft+', status=no, ,';

		    var pp = window.open("","", winprops);// "width=" + myWidth + ", height=" + eval(myHeight + 35) + ",status=no,scrollbars=no,resize=no");
//		    var pp = window.open("","", "width=" + myWidth + ", height=" + eval(myHeight + 35) + ",status=no,scrollbars=no,resize=no");
		    // Just in case width and height are ignored
            pp.resizeTo(myWidth, eval(myHeight+50));
            // Just in case left and top are ignored
            pp.moveTo(wleft, wtop);
            pp.focus();

			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
			pp.document.writeln('<HTML><HEAD><title>Fullmobile - Media Preview</title>');
			pp.document.writeln('<base target="_self"></HEAD>');
			//Adding Body Tag
			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
			//Adding form Tag
			pp.document.writeln('<form  method="post">');
			//Creating two buttons Print and Close within a table
			pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
			//Writing media player area of the calling page		
			pp.document.writeln("<object id='MPlyr' classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" align=\"left\" width=\"320\" height=\"240\" type=\"application/x-oleobject\">"); 
            pp.document.writeln("<PARAM NAME=\"URL\" VALUE=\"" + mediaPath + "\">");
            pp.document.writeln("<PARAM NAME=\"AutoSize\" VALUE=\"1\">");
            pp.document.writeln("<PARAM NAME=\"AutoStart\" VALUE=\"True\">"); 
            pp.document.writeln("<PARAM NAME=\"uiMode\" VALUE=\"none\">"); 
            pp.document.writeln("<PARAM NAME=\"PlayCount\" VALUE=\"1\">");
            pp.document.writeln("<PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"True\">");
            pp.document.writeln("<PARAM NAME=\"ShowAudioControls\" VALUE=\"0\">");
            pp.document.writeln("<PARAM NAME=\"ShowDisplay\" VALUE=\"0\"> ");
            pp.document.writeln("<PARAM NAME=\"ShowPositionControls\" VALUE=\"-1\">");
            pp.document.writeln("<PARAM NAME=\"ShowStatusBar\" VALUE=\"0\">");
            pp.document.writeln("<PARAM NAME=\"ShowTracker\" VALUE=\"0\">");
            pp.document.writeln("</object>");
           
			//Ending Tag of </form>, </body> and </HTML>
			pp.document.writeln('</form></body></HTML>');		
		}
		
		
		// Show picture in a separate window	
		function FM_ShowFile(fileUrl)
		{
		    // Ensure proper picture size
			var myWidth = 600;
			var myHeight = 400;
            //Creating new page
		    // add 35 pixels  to the height for the menu
            var wleft = (screen.width - myWidth) / 2;
            var wtop = (screen.height - myHeight) / 2;
            var winprops = 'height='+eval(myHeight+50)+',width='+myWidth+',top='+wtop+',left='+wleft+', ,scrollbars=yes,resizable=yes';

		    var pp = window.open("","", winprops);// "width=" + myWidth + ", height=" + eval(myHeight + 35) + ",status=no,scrollbars=no,resize=no");
//		    var pp = window.open("","", "width=" + myWidth + ", height=" + eval(myHeight + 35) + ",status=no,scrollbars=no,resize=no");
		    // Just in case width and height are ignored
            pp.resizeTo(myWidth, eval(myHeight+50));
            // Just in case left and top are ignored
            pp.moveTo(wleft, wtop);
            pp.focus();

            pp.document.location = fileUrl;
//            
//			//Adding HTML opening tag with <HEAD> … </HEAD> portion 
//			pp.document.writeln('<HTML><HEAD><title>REWA - Media Preview</title>');
//			pp.document.writeln('<base target="_self"></HEAD>');
//			//Adding Body Tag
//			pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
//			//Adding form Tag
//			pp.document.writeln('<form  method="post">');
//			//Creating two buttons Print and Close within a table
//			pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
//			//Writing print area of the calling page
//			pp.document.writeln("<script type=\"text/javascript\"> </script>");
//			//Ending Tag of </form>, </body> and </HTML>
//			pp.document.writeln('</form></body></HTML>');
		
}

// Use one function for multiple text areas on a page 
// Limit the number of characters per textarea 
// Begin
///fieldID: the ID of the TextArea to monitor
// cntfieldID : the control that displays the remaining characters for the monitored control.
function textCounter(fieldID,cntfieldID, intMaxlimit) 
{
    var field, cntfield;
    field = document.getElementById(fieldID);
    cntfield = document.getElementById(cntfieldID);
    
    if (field.value.length > intMaxlimit) // if too long...trim it!
        field.value = field.value.substring(0, intMaxlimit);
    // otherwise, update 'characters left' counter
    else
        cntfield.value = intMaxlimit - field.value.length;
}
//  End