/*
    CMS Backend - Interfata de administrare a CMS-urilor dezvoltate de Felix Manea
    Copyright (C) 2007-2008 Felix Manea (felix.manea@gmail.com)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function preloadImages(imgArray){
	var images = new Array();
	for(i=0;i<imgArray.length;i++)
	{
		t = new Image();
		t.src = '<?=base_url?>'+imgArray[i];
		images.push(t);
	}
}

function getElById(elName)
{
	el = document.getElementById(elName);
	if(typeof(el) == 'undefined' || el == null) return false;
	return el;
}

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function getElementHeight(Elem) {
	if (elem && elem.clip && elem.clip.height) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else
	{
		if(document.getElementById)
		{
			var elem = document.getElementById(Elem);
		}
		else if (document.all)
		{
			var elem = document.all[Elem];
		}
		if (elem)
		{
			if(elem.style && elem.style.pixelHeight)
			{
				yPos = elem.style.pixelHeight;
			}
			else
			{
				yPos = elem.offsetHeight;
			}
		}
		else return false;
		return yPos;
	}
}

function getElementWidth(Elem) {
	if (elem && elem.clip && elem.clip.width) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else
	{
		if(document.getElementById)
		{
			var elem = document.getElementById(Elem);
		}
		else if (document.all)
		{
			var elem = document.all[Elem];
		}
		if (elem)
		{
			if(elem.style && elem.style.pixelWidth)
			{
				xPos = elem.style.pixelWidth;
			}
			else
			{
				xPos = elem.offsetWidth;
			}
		}
		else return false;
		return xPos;
	}
}

function bigPicture(image, base_url)
{
	if(typeof(image) == 'undefined')
	{
		img = document.getElementById('imagine_produs');
		if(typeof(img) == 'undefined') return;
		image = img.src;
	}
	if(typeof(base_url) == 'undefined') base_url = '';
	window.open(base_url + 'imgpreview.php?src='+escape(image),'_bigPicture','top=0, left=0, scrollbars=1, status=0, width=100, height=100, resizable=0');
}

function getScreenResolution()
{
	var screenW = 640, screenH = 480;
	if (parseInt(navigator.appVersion)>3) {
	 screenW = screen.width;
	 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape"
			&& parseInt(navigator.appVersion)==3
			&& navigator.javaEnabled()
		 )
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenW = jScreenSize.width;
	 screenH = jScreenSize.height;
	}
	return new Array(screenW, screenH);
}


function resizeWindow(w,h) {
 //trebuie recalculat in fct de marime sa faca sau nu bara orizontala
 w+=16;
 h+=3;

 resolution = getScreenResolution();
 if(w > resolution[0]) w = resolution[0];
 if(h > resolution[1]) h = resolution[1] - 50;

 if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
		top.outerWidth=w;
		top.outerHeight=h;
	 }
	 else top.resizeTo(w,h);
 }
}

function getWindowSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {width: myWidth, height: myHeight}
}

function resizeElHeightByWindowSize(element, difference){
	w = getWindowSize();
	height = (w.height - difference);
	//if(getElementHeight(element) <= height)
	document.getElementById(element).style.height = height+'px';
}

function resizeAll(){
	resizeElHeightByWindowSize('pageContent', 286);
	//alert(getElementHeight('pageContent'));
	//document.getElementById('pagePlanta').style.height = (getElementHeight('pageContent')-304)+'px';
}

function getImageFromSrc(src){
	var regexp = /^(.*\/)?([^\/]+)$/;
	if(!regexp.exec(src)) return alert("Nume fisier trimis invalid: "+src);
	return RegExp.$2;
}

var gAutoPrint = true;
function printFriendly()
{
	if (document.getElementById!= null)
	{
		var html = '<HTML>\n<HEAD>\n';
		if (document.getElementsByTagName!= null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '\n</HE' + 'AD>\n<BODY>\n';
		var printPageElem = document.getElementById("printReady");

		if (printPageElem!= null)
		{
			html +='\n<div id="BodyBoxesHolder">\n';
			html += printPageElem.innerHTML;
//			html.replace("\<h1\>", "\<div class='hh1'\>");
//			html.replace("\</h1\>", "\</div\>");
			html +='\n</div>\n';
		}
		else
		{
			alert("We cannot find the printable section.");
			return;
		}

		html += '\n</BO' + 'DY>\n</HT' + 'ML>';

		var printWin = window.open("","printFriendly");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("This function can be used only \n by browsers supporting JavaScript (active).");
	}
}

//ascunde / afiseaza un element
function showHideEl(elName, imgName, img1, img2)
{
	el = document.getElementById(elName);
	if(typeof(el) == 'undefined') return false;
	if(el.style.display == 'none')
	{
		el.style.display = 'block';
		chImg(imgName, img2);
	}
	else
	{
		el.style.display = 'none';
		chImg(imgName, img1);
	}
}

//schimba imaginea
function chImg(elName, img)
{
	el = document.getElementById(elName);
	if(typeof(el) == 'undefined') return false;
	el.src = img;
}

// This function sets a client-side cookie as above.  Only first 2 parameters are required
// Rest of the parameters are optional. If no szExpires value is set, cookie is a session cookie.
//
// Prototype : setCookie(szName, szValue [,szExpires] [,szPath] [,szDomain] [,bSecure])
//******************************************************************************************


function setCookie(szName, szValue, szExpires, szPath, szDomain, bSecure)
{
 	var szCookieText = 	   escape(szName) + '=' + escape(szValue);
	szCookieText +=	 	   (szExpires ? '; EXPIRES=' + szExpires.toGMTString() : '');
	szCookieText += 	   (szPath ? '; PATH=' + szPath : '');
	szCookieText += 	   (szDomain ? '; DOMAIN=' + szDomain : '');
	szCookieText += 	   (bSecure ? '; SECURE' : '');
	
	document.cookie = szCookieText;
}

//******************************************************************************************
// This functions reads & returns the cookie value of the specified cookie (by cookie name) 
//
// Prototype : getCookie(szName)
//******************************************************************************************

function getCookie(szName)
{
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{
       	var arr = 		  document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}

//******************************************************************************************
// To delete a cookie, pass name of the cookie to be deleted
//
// Prototype : deleteCookie(szName)
//******************************************************************************************

function deleteCookie(szName)
{
 	var tmp = 	  			 	 getCookie(szName);
	if(tmp) 
	{ setCookie(szName,tmp,(new Date(1))); }
}

// special function

var marimeFontDefault = 10;
var marimeFontMinim = 8;
var marimeFontMaxim = 18;

var marimeFontDefault1 = 0;
var marimeFontMinim1 = -2;
var marimeFontMaxim1 = 8;

xx=getCookie('marimeFontDefault1');
if(xx!=null) marimeFontDefault1=parseInt(xx);

//var stiluri=new Array("p","h1", "h2", "h3", "h4", "h5", "h6", "Heading7", "Heading8", "Heading9", "Heading10", "a");
var stiluri=new Array("p","h1", "h2", "h3", "h4", "h5", "h6", "Heading7", "Heading8", "Heading9", "Heading10", "a", "ul", "li","td", "th", "div", "span");
var siz_stiluri=new Array(12,18,16,12,11,15,12,12,14,16,12,12,12,12,12,12,12,12);
//var excepted_class= new Array("no_grow");
var excepted_class= "no_grow";
function init_stiles_sizes(){
	var theDiv=document.getElementById('BodyBoxesHolder');
	for(i=0; i<stiluri.length; i++){
		var p = theDiv.getElementsByTagName(stiluri[i]);
		s=11;
		if(p.length>0){
			if(p[0].style.fontSize ) {
				s = parseInt(p[0].style.fontSize.replace("px",""));
			}
		}
		siz_stiluri[i]=s;
//		alert(stiluri[i]+"  "+siz_stiluri[i]);
	}
}
		
function maresteFont1()
{
	theDiv=document.getElementById('BodyBoxesHolder');
	marimeFontDefault = marimeFontDefault+1;
	if (marimeFontDefault > marimeFontMaxim) {marimeFontDefault = marimeFontMaxim;}
	theDiv.style.fontSize=marimeFontDefault+"px";
}

function micsoreazaFont1()
{
	theDiv=document.getElementById('BodyBoxesHolder');
	marimeFontDefault = marimeFontDefault-1;
	if (marimeFontDefault < marimeFontMinim) {marimeFontDefault = marimeFontMinim;}
	theDiv.style.fontSize=marimeFontDefault+"px";
}

function increaseFont()
{
	theDiv=document.getElementById('BodyBoxesHolder');
	marimeFontDefault1 = marimeFontDefault1+1;
	if (marimeFontDefault1 > marimeFontMaxim1) {marimeFontDefault1 = marimeFontMaxim1;}
	for(i=0; i<stiluri.length; i++){
		p = theDiv.getElementsByTagName(stiluri[i]);
		for(j=0;j<p.length;j++) {
//			if(  p[j].className !=excepted_class){
			if( !HasClassName(p[j], excepted_class)){
				
  	  	p[j].style.fontSize=(siz_stiluri[i]+marimeFontDefault1)+"px";
			}
		}
	}
	setCookie('marimeFontDefault1',marimeFontDefault1);
}

function decreaseFont()
{
	theDiv=document.getElementById('BodyBoxesHolder');
	marimeFontDefault1 = marimeFontDefault1-1;
	if (marimeFontDefault1 < marimeFontMinim1) {marimeFontDefault1 = marimeFontMinim1;}
	for(i=0; i<stiluri.length; i++){
		p = theDiv.getElementsByTagName(stiluri[i]);
		for(j=0;j<p.length;j++) {
 			if(  p[j].className !=excepted_class){
		   	p[j].style.fontSize=(siz_stiluri[i]+marimeFontDefault1)+"px";
			}
		}
	}
	setCookie('marimeFontDefault1',marimeFontDefault1);
}

function AplicaFont()
{
	theDiv=document.getElementById('BodyBoxesHolder');
	for(i=0; i<stiluri.length; i++){
		p = theDiv.getElementsByTagName(stiluri[i]);
		for(j=0;j<p.length;j++) {
    	p[j].style.fontSize=(parseInt(siz_stiluri[i])+marimeFontDefault1)+"px";
		}
	}
}

function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

var gAutoPrint = true;
function printFriendly()
{
	if (document.getElementById!= null)
	{
		var html = '<HTML>\n<HEAD>\n';
		if (document.getElementsByTagName!= null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '\n</HE' + 'AD>\n<BODY>\n';
		var printPageElem = document.getElementById("printReady");

		if (printPageElem!= null)
		{
			html +='\n<div id="BodyBoxesHolder">\n';
			html += printPageElem.innerHTML;
//			html.replace("\<h1\>", "\<div class='hh1'\>");
//			html.replace("\</h1\>", "\</div\>");
			html +='\n</div>\n';
		}
		else
		{
			alert("We cannot find the printable section.");
			return;
		}

		html += '\n</BO' + 'DY>\n</HT' + 'ML>';

		var printWin = window.open("","printFriendly");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("This function can be used only \n by browsers supporting JavaScript (active).");
	}
}

//ascunde / afiseaza un element
function showHideEl(elName, imgName, img1, img2)
{
	el = document.getElementById(elName);
	if(typeof(el) == 'undefined') return false;
	if(el.style.display == 'none')
	{
		el.style.display = 'block';
		chImg(imgName, img2);
	}
	else
	{
		el.style.display = 'none';
		chImg(imgName, img1);
	}
}

// ***********************************************************
//
//  date format function
//
// ***********************************************************

// DATE FORMAT

var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date();
		if (isNaN(date)) throw new SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};


// ----------------------------------------------------------------------------
// HasClassName
//
// Description : returns boolean indicating whether the object has the class name
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function HasClassName(objElement, strClass)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // we found it
            return true;

            }

         }

      }

   // if we got here then the class name is not there
   return false;

   }
// 
// HasClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// AddClassName
//
// Description : adds a class to the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function AddClassName(objElement, strClass, blnMayAlreadyExist)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // if the new class name may already exist in list
      if ( blnMayAlreadyExist )
         {

         // get uppercase class for comparison purposes
         var strClassUpper = strClass.toUpperCase();

         // find all instances and remove them
         for ( var i = 0; i < arrList.length; i++ )
            {

            // if class found
            if ( arrList[i].toUpperCase() == strClassUpper )
               {

               // remove array item
               arrList.splice(i, 1);

               // decrement loop counter as we have adjusted the array's contents
               i--;

               }

            }

         }

      // add the new class to end of list
      arrList[arrList.length] = strClass;

      // add the new class to beginning of list
      //arrList.splice(0, 0, strClass);
      
      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   else
      {

      // assign modified class name attribute      
      objElement.className = strClass;
   
      }

   }
// 
// AddClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// RemoveClassName
//
// Description : removes a class from the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to remove
//
function RemoveClassName(objElement, strClass)
   {

   // if there is a class
   if ( objElement.className )
      {

      // the classes are just a space separated list, so first get the list
      var arrList = objElement.className.split(' ');

      // get uppercase class for comparison purposes
      var strClassUpper = strClass.toUpperCase();

      // find all instances and remove them
      for ( var i = 0; i < arrList.length; i++ )
         {

         // if class found
         if ( arrList[i].toUpperCase() == strClassUpper )
            {

            // remove array item
            arrList.splice(i, 1);

            // decrement loop counter as we have adjusted the array's contents
            i--;

            }

         }

      // assign modified class name attribute
      objElement.className = arrList.join(' ');

      }
   // if there was no class
   // there is nothing to remove

   }
// 
// RemoveClassName
// ----------------------------------------------------------------------------
  
function CharityRecalc(){
	var frm=document.forms[0];
	for(i=0; i<frm.elements.length; i++){
		if (frm.elements[i].name.indexOf('q1_')==0){
			q1=frm.elements[i];
		}else if(frm.elements[i].name.indexOf('q2_')==0){
			q2=frm.elements[i];
		}else if(frm.elements[i].name.indexOf('q3_')==0){
			q3=frm.elements[i];
		}else if(frm.elements[i].name.indexOf('q4_')==0){
			q4=frm.elements[i];
		}else if(frm.elements[i].name.indexOf('q5_')==0){
			q1=frm.elements[i];
		}else if(frm.elements[i].name.indexOf('result_')==0){
			result=frm.elements[i];
		}
	}
/*	
	q1=frm.Q1;
	q2=frm.Q2;
	q3=frm.Q3;
	q4=frm.Q4;
	result=frm.result;
alert(q1.name);
alert(q2.name);
alert(q3.name);
alert(q4.name);
alert(result.name);
*/	
	var total=0;
//	alert(q1.value.charCodeAt(0));
	q1v=q1.value.replace(String.fromCharCode(163),"");
	q4v=q4.value.replace(String.fromCharCode(163),"");
	
	if(q1v=="1,000,000" ){
			total = total+60;
			if(q2.value=="Yes"){
				total = total+20;
			}
	}else if(q1v=="2,000,000" ){
			total = total+80;
			if(q2.value=="Yes"){
				total = total+26;
			}
	}else if(q1v=="5,000,000" ){ 
			total = total+100;
			if(q2.value=="Yes"){
				total = total+30;
			}
	}
	
	if(q3.value=="Yes"){
		total = total+80;
	}

	if(q4v=="1,000" ){
			total = total+30;
	}else if(q4v=="1,500" ){
			total = total+45;
	}else if(q4v=="2,000" ){
			total = total+60;
	}
	//ITP
	total=total*1.05;
	//fee
	total=total+20;
	
	result.value= total;
}

function BlockingCharity(){
	var frm=document.forms[0];
	c1=frm.Turnover;
	c2=frm.GrossAssets;
	c3=frm.Agree;
	c4=frm.UKBased;
	c5=frm.AbuseCover;
	
	q1=frm.Q1;
	q2=frm.Q2;
	q3=frm.Q3;
	q4=frm.Q4;
	
	btn_submit=frm.btn_submit;
//	alert(c1.selectedIndex );
	if(!(c1.selectedIndex==1 && c2.selectedIndex==1 && c3.selectedIndex==1 && c4.selectedIndex==1 && c5.selectedIndex==1 )){
//	if(!(c1=="Yes" && c2=="Yes" && c3=="Yes" && c4=="Yes" && c51=="Yes" )){
	 q1.disabled =true;
	 q2.disabled =true;
	 q3.disabled =true;
	 q4.disabled =true;
	 btn_submit.disabled =true;
	}else{
	 q1.disabled =false;
	 q2.disabled =false;
	 q3.disabled =false;
	 q4.disabled =false;
	 btn_submit.disabled =false;
	}
}

function OnChangCal(control){
	c0=	document.getElementById(control);
	cd=	document.getElementById(control+'_dayy');
	cm=	document.getElementById(control+'_monthh');
	cy=	document.getElementById(control+'_yearr');
	c0.value=GetSelectedValue(cd)+'/'+GetSelectedValue(cm)+'/'+GetSelectedValue(cy);
}

function GetSelectedValue(control){
	return control.options[control.selectedIndex].value;
}