﻿// JScript File
// Syed Raheel Ali
// General        
        function IsNumeric(obj)
        {
            //if ((event.keyCode < 48 || event.keyCode > 57))
            //event.returnValue = false;
            
            if((event.keyCode >= 48 && event.keyCode <= 57)|| (event.keyCode >= 96 && event.keyCode <= 105)||(event.keyCode == 8 ) || 
               (event.keyCode == 9) || (event.keyCode == 12) || (event.keyCode == 27) || 
               (event.keyCode == 37) || (event.keyCode == 39) || (event.keyCode == 46) || 
               (event.keyCode == 219) || (event.keyCode == 221) || (event.keyCode == 189))
               {event.returnValue = true;}
               else
               {event.returnValue = false;}
        } 
        
        
        var n;
        var p;
        var p1;
            function ValidatePhone(){
            p=p1.value
            if(p.length==3){
	            //d10=p.indexOf('(')
	            pp=p;
	            d4=p.indexOf('(')
	            d5=p.indexOf(')')
	            if(d4==-1){
		            pp="("+pp;
	            }
	            if(d5==-1){
		            pp=pp+")";
	            }
	            //pp="("+pp+")";
	            document.getElementById(n).value ="";
	            document.getElementById(n).value =pp;
	            
	            //document.frmPhone.txtphone.value="";
	            //document.frmPhone.txtphone.value=pp;
            }
            if(p.length>3){
	            d1=p.indexOf('(')
	            d2=p.indexOf(')')
	            if (d2==-1){
		            l30=p.length;
		            p30=p.substring(0,4);
		            //alert(p30);
		            p30=p30+")"
		            p31=p.substring(4,l30);
		            pp=p30+p31;
		            //alert(p31);
		            document.getElementById(n).value ="";
	                document.getElementById(n).value =pp;
		            //document.frmPhone.txtphone.value="";
		            //document.frmPhone.txtphone.value=pp;
	            }
	            }
            if(p.length>5){
	            p11=p.substring(d1+1,d2);
	            if(p11.length>3){
	            p12=p11;
	            l12=p12.length;
	            l15=p.length
	            //l12=l12-3
	            p13=p11.substring(0,3);
	            p14=p11.substring(3,l12);
	            p15=p.substring(d2+1,l15);
	            document.getElementById(n).value ="";
	            
	            //document.frmPhone.txtphone.value="";
	            pp="("+p13+")"+p14+p15;
	            document.getElementById(n).value =pp;
	            //obj1.value="";
	            //obj1.value=pp;
	            }
	            l16=p.length;
	            p16=p.substring(d2+1,l16);
	            l17=p16.length;
	            if(l17>3&&p16.indexOf('-')==-1){
		            p17=p.substring(d2+1,d2+5);
		            p18=p.substring(d2+5,l16);
		            p19=p.substring(0,d2+1);
		            //alert(p19);
	            pp=p19+p17+"-"+p18;
	            document.getElementById(n).value ="";
	            document.getElementById(n).value =pp;
	            //obj1.value="";
	            //obj1.value=pp;
	            }
            }
            //}
            setTimeout(ValidatePhone,100)
            }
            
            function getIt(m){
            
                if(m != null)
                {
                    //alert(document.getElementById(m).value);
                    n = m.name;
                    //p1=document.forms[0].elements[n]
                    p1 = m;
                    ValidatePhone();
                
//                    var objValue;
//                    objValue = document.getElementById(m).value;
//                    alert(objValue);
//                    
//                    if(objValue.length <=15)
//                    {   
//                        n = m.name;
//                        //p1=document.forms[0].elements[n]
//                        p1 = m;
//                        ValidatePhone();
//                    }
//                    else
//                    {
//                        event.returnValue =  false;
//                    }
                }
            }
        
            function testphone(obj1){
            p=obj1.value
            //alert(p)
            p=p.replace("(","")
            p=p.replace(")","")
            p=p.replace("-","")
            p=p.replace("-","")
            //alert(isNaN(p))
            if (isNaN(p)==true){
            alert("Check phone");
            return false;
            }
        }
        
// Fake Upload File

var W3CDOM = (document.createElement && document.getElementsByTagName);

    function initFileUploads() {
    
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='/style%20library/en-us/core%20styles/images/ico-browse.gif';
	image.className = 'FileImage';
	
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
			
			
			
		}
	}
}
/// Fake File End   

//<!-- Idea by:  Nic Wolfe (Nic@TimelapseProductions.com) -->
//<!-- Web URL:  http://fineline.xs.mw -->

//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

//<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=280,left = 237,top = 59');");
}
// End -->   

 function CallPrinterUI() 
            {
                var topicContent = "";
                //alert("a");

                  //document.getElementById("replaceContent").style.display='none';

                  //document.getElementById("contDetails").className="tabcontentPrint"; 
                  
                  var prtContentUI = document.getElementById("MyDataUI");

                  var pageTitle = document.getElementById("innerpageTitle").innerHTML; 
                  
                  var WinPrint = window.open('','','left=0,top=0,width=800,height=600,toolbar=0,scrollbars=1,status=0'); 

 
                  WinPrint.document.write("<html><head><link rel='stylesheet' type='text/css' href='/Style Library/en-us/core styles/gcaa_Print.css' /></head><body class=printBody><table  border=0 width=90%  align=center><tr><td align=left><img src='/Style Library/en-us/Core Styles/images/Printlogo.gif'><br><br></td></tr><tr><td><strong style=font-size:13>" + pageTitle + "</strong></td></tr><tr><td style='text-align:justify;'><br>" + prtContentUI.innerHTML + "<br></td></tr> <tr ><td style='padding-left:15px'>© 2008, Cubic Art Technologies L.L.C, all rights reserved </td></tr></table></body></html>"); 
                  WinPrint.document.close(); 
                  WinPrint.focus(); 
                  WinPrint.print();
                  // document.getElementById("replaceContent").style.display='block';
                  //WinPrint.close(); 
               
            }

  

       


